AJAX: admin-ajax.php is adding extra content to my script’s response – how to exclude header, footer, etc.?
AJAX: admin-ajax.php is adding extra content to my script’s response – how to exclude header, footer, etc.?
AJAX: admin-ajax.php is adding extra content to my script’s response – how to exclude header, footer, etc.?
One thing you could do is set a variable in the archive.php like <script>var isArchive = true;</script>. Or in any template do if (is_archive()) { /* set the variable */ }. And then in the JS file do if (typeof isArchive != ‘undefined’) { } but there are probably way more elegant solutions that I’m … Read more
Try to apply some function like htmlspecialchars() on your query before searching for it, it will translate your special chars into HTML entities.
Open the website with Web Developer tools or Browser inspection tools ( Firebug )etc and then Run “Console”. Refresh your website and see the Ajax calls. Check the POST window in Ajax call to see action script. That’d tell you the exact function being called.
How to use nonces for frontend AJAX voting if the page gets cached?
Tie the sending of an ajax request to WordPress hooks
The issue turned out to be elsewhere. But I did learn that there is no way to overwrite the queried URL directly, as it comes from $_SERVER variables. The answer here had some code for anyone who wants to do that: https://stackoverflow.com/questions/10739721/wordpress-ajax-parse-url
A very simple experiment… add_action(‘admin_init’,’get_header’); add_action(‘admin_init’,’get_footer’); … will demonstrate that the get_header() and get_footer() functions work on the back end as well as the front, though you will need to adjust for numerous markup problems and other issues. Honestly, you question seems to be “how do I get the site header and footer and use … Read more
wp_ajax_action, wp_ajax_nopriv_action not working
How to check for dependencies for a specific page and enqueue them