How to use ajax to get multiple outputs?

Instead of passing two parameters to function you can pass the array of two values like this : $results[‘args1’] = “value1”; $results[‘args2’] = “value2”; echo json_encode($results); and then get it in success function like this : success:function(results){ jQuery(“.semester_selection1”).append(results.args1); // This appends value1 jQuery(“.semester_selection2”).append(results.args2); // This appends value2 }

Add Ajax to rating button

I’ll only outline how to do it since there are plenty of answers on this site that address how AJAX works in WordPress. Just check out the ajax tag. Yes, you’ll need some javascript to watch for when the button is clicked. When it is, you send a custom action, say ‘myaction’, and the post … Read more

Ajax function not returning any results

Regarding the jQuery part: Everything looks OK, except for the fact that we have no way of knowing which URL you are ultimately pointing to. You could see the URL, the headers you’re sending and the server’s response by using Firebug or WebKit’s developer tools in Chrome or Safari, and editing the code accordingly. Since … Read more

Specify ABSPATH in jQuery url

If your JavaScript is running in the admin, you don’t need to set an explicit path to admin-ajax.php. It’s always available as a JS variable called “ajaxurl”. You can see an example of this in the Codex, under the heading “AJAX on the Administration Side” Ajaxurl is, unfortunately, not available on the frontend by default. … Read more