Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

In relation to this question, I don't understand the meaning of:

Instead of sending the ajax request to the admin-ajax.php, send it to the same url (using js window.location.href ) but including an endpoind that can be 'mobile' or 'desktop'. An hook into template_include filter will do the rest. Hope it's clear

This is my call:

jQuery.ajax({
        url: my_ajax_script.ajaxurl,
        data: ({action : 'get_mobile_template'}),
        success: function(data) {
        document.write(data);
        }
    });

Is there anybody who understands this matter and is able to come up with an example?

share|improve this question
1  
To me you MUST use admin-ajax.php for your AJAX requests in WordPress –  JMau Aug 27 '13 at 11:25
    
but then, how do you conditionally load stuff into the head then? e.g. page specific css styles and scripts. Because if I put get_header() into the template that ajax loads, I get a great white page... –  Andrea Puiatti Aug 27 '13 at 11:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.