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

Storing temporary data for a custom post type

If you’re using custom post types, i’d save those date entries as post_meta entries (http://codex.wordpress.org/Function_Reference/add_post_meta). So if your client clicks on a date, you start an ajax request to your plugin/theme file to add or remove a meta entry. you can create one meta_entry named _availability for example and save all dates there (you can … Read more

How to call ajax in plugin file

Use the built-in wordpress Ajax actions: Your jquery will look like this: $(‘#ajax_form’).bind(‘submit’, function() { var form = $(‘#ajax_form’); var data = form.serialize(); data.action = ‘MyPlugin_GetVars’ $.post(‘/wp-admin/admin-ajax.php’, data, function(response) { alert(response); }); return false; Your plugin code something like: add_action(“wp_ajax_MyPlugin_GetVars”, “MyPlugin_GetVars”); add_action(“wp_ajax_nopriv_MyPlugin_GetVars”, “MyPlugin_GetVars”); function MyPlugin_GetVars(){ global $wpdb; // use $wpdb to do your inserting //Do … Read more