To test your AJAX is working
add_action( 'wp_ajax_editCommittee', 'test_ajax_request' );
add_action( 'wp_ajax_nopriv_editCommittee', 'test_ajax_request' );
function test_ajax_request() {
echo "Request: " . PHP_EOL;
var_dump( $_REQUEST );
exit;
}
And update your request to move the action
into the data
sent:
jQuery (document).ready (function($) {
$ (".edit_tr").click (function() {
var commitID = $ (this).attr ('id');
// on click, hide the text
$ ("#name_" + commitID).hide ();
$ ("#created_" + commitID).hide ();
$ ("#status_" + commitID).hide ();
$ ("#disbanded_" + commitID).hide ();
// on click, show the input fields for editing
$ ("#name_input_" + commitID).show ();
$ ("#created_input_" + commitID).show ();
$ ("#status_input_" + commitID).show ();
$ ("#disbanded_input_" + commitID).show ();
}).change (function() {
var commitID = $ (this).attr ('id');
var name = $ ("#name_input_" + commitID).val ();
var date_created = $ ("#created_input_" + commitID).val ();
var status = $ ("#status_input_" + commitID).val ();
var disbanded = $ ("#disbanded_input_" + commitID).val ();
var dataString = {
action: 'editCommittee',
id: commitID,
name: name,
date_created: date_created,
status: status,
disbanded: disbanded
};
console.log (dataString);
// can place loading image here
$.ajax({
type : "post",
url: "/wp-admin/admin-ajax.php",
data: dataString,
error: function(xhr, status, error) {
var err = eval ("(" + xhr.responseText + ")");
alert (err.Message);
},
success: function(response) {
$ ("#name_" + commitID).html (name);
$ ("#created_" + commitID).html (date_created);
$ ("#status_" + commitID).html (status);
$ ("#disbanded_" + commitID).html (disbanded);
console.log ("Got this from server: " + response);
console.log ("This is what happened to data: ");
console.dir (dataString);
}
});
});
I you still don't get anything it's probably your URL. You can try to localize the admin-ajax.php
URL like this answer shows: http://stackoverflow.com/a/22007593/5623301