0

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?

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.