Load page HTML content through AJAX

An AJAX request is a request from a client like any other request. Just request the URL like normal, but with Javascript. As far as that goes, this should be simple. If you’ve done item #2– “I’ll wrap the header/footer/sidebars…”– correctly there should be no problem except that page specific functions won’t run. That is … Read more

admin-ajax.php not loading anymore

It turns out the problem was a configuration server problem. The admin turned off Open_basedir and all of my headaches, at least on this front, are gone now. I am not sure what open_basedir does exactly, but I think it was originally pointing to a folder outside wordpress, so the Ajax calls in the dashboard … Read more

ajax in admin menu

add_action(‘wp_ajax_ring_callback’, ‘ring_callback’); Should be the hook you must be using to enable ring_callback function call.

Ajax page load without reload

You can re-initialize all the scripts once again inside the AJAX success. // Fetch the scripts scripts=””; if ( scripts.length ) scripts.detach(); scripts = response.find(‘script’); // Add the scripts scripts.each(function(){ var script = jQuery(this), scriptText = script.html(), scriptNode = document.createElement(‘script’); try { // doesn’t work on ie… scriptNode.appendChild(document.createTextNode(scriptText)); contentNode.appendChild(scriptNode); } catch(e) { // IE has … Read more

Next Ajax call doesn’t work

As the “Next”, “Prev” links are the part of AJAX responded content, you need to use either ‘live’ or ‘on’ based upon the jQuery version you are using. jQuery(document).ready(function($) { var cadenaNext=””; var cadenaPrev=”; $(‘#ajax-form-next’).live(“submit”, function(e) { e.preventDefault(); jQuery.post(MyAjax.url, {action : ‘next_posts’ ,cadenaNext : $(‘#nextPosts’).val(), cadenaPrev : $(‘#actualPosts’).val() }, function(response) { $(‘#posts_container’).hide(1000); setTimeout(function() {$(‘#posts_container’).html(response).show(1000);}, 1000); … Read more

I get a 0 after the result of my ajax requests

WordPress does that by default at the end of admin-ajax.php. It kind of assumes you’ll use one of wp_send_json(), wp_send_json_success(), or wp_send_json_error() to communicate your process’ state (or at least terminate the script yourself). All of those use wp_die() to terminate the script after sending the response. It’s sort of a catch-all response.

Replace link with form to pass variables to javascript / ajax

Worked out the answer with input from non WP-oriented forum and edited above to show. In short the variables were retrieved from WITHIN the js function using getElementByID and prevented error on non-action form with event.preventDefault(); like so: function glitch_player_display() { user_input = document.getElementById(“user_input”).value ? document.getElementById(“user_input”).value : 2; generated_var = document.getElementById(“generated_var”).value ? document.getElementById(“generated_var”).value : “Default_Var”; … Read more