Ajax requests with different WordPress Address and Site Address setup

Depending on how you’re mapping somewebsite.com, you can probably just define ajaxurl differently: var ajaxurl=”http://www.somewebsite.com/admin-ajax.php”; If you need something more generalizable, you could filter admin_url, sniff out whether it’s asking for admin-ajax.php, and if so, then rewrite it using home_url() or something like that. Getting cross-domain ajax to work is possible (with a proxy approach, … Read more

Call the content of a page in AJAX in WordPress

I already mentioned in the comments, that there’re preferred ways to load your scripts. The most important is to define the dependencies and the using the proper hooks. The following part won’t work like this: $(document).ready(function() { $(“body”).SEOParallax(); $(“body”).delegate(“a”, “click”, function() { $(‘html, body’).animate({ scrollTop: $($(this).attr(“href”)).offset().top }, 1200); return false; }); }); The WordPress Javascript … Read more

Filtering posts by multiple taxonomies

First off, you should be using WP_Query vs query_posts. Have a look at the Taxonomy Parameters. Mainly tax_query and relation. // Repost from link above $args = array( ‘post_type’ => ‘post’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘movie_genre’, ‘field’ => ‘slug’, ‘terms’ => array( ‘action’, ‘comedy’ ) ), array( ‘taxonomy’ => ‘actor’, … Read more

Timeout on Admin-Ajax?

There is always a timeout, be it TCP or the PHP execution time ( unless you configure your server in a weird way, PHP will kill long running tasks ). If you need to do a lot of work you should: Break it into smaller pieces Plugins like regen thumbnails retrieve a list of items … Read more

ajax and nonce when JavaScript is in a seperate file

You can localize your script and pass the nonce and ajax url to the script.Learn more about script localization. function wpse_206839() { // Register our script just like we would enqueue it – for WordPress references wp_register_script( ‘my-special-script’, ‘directory/my-special-script.js’, array( ‘jquery’ ), false, true ); // Create any data in PHP that we may need … Read more

How to wp_query posts with ajax

I would like to make a series of comments, but the overall length would be too long for a comment, so I have to write an answer. You should state what is working and what is failing, and tell us what you have tried to get it working. Looking at your code is too general. … Read more

Display a function using AJAX

You’re not hooking the function to wp_ajax correctly. You need to replace the my_action part with your action name that you’re using the in AJAX request. In your case it’s display_user_table. You also need to hook it on to wp_ajax_nopriv so that it works for logged out users. Here’s your hook with those changes: add_action(‘wp_ajax_diplay_user_table’, … Read more