These are my two jQuery functions
$(".enable_button").click(function(){
var server_name = $(this).attr("title");
$.get("ajax/server_ajax.php?action=enable&server_name=" + server_name), function(data) {
alert(data);
}
});
$(".disable_button").click(function(){
var server_name = $(this).attr("title");
$.get("ajax/server_ajax.php?action=disable&server_name=" + server_name), function(data) {
alert(data);
}
});
Pretty easy to see what they do, on a button click they enable or disable a server by passing an action parameter and server_name parameter to ajax/server_ajax.php. Everthing works, but for some reason the data being returned is never being alert’d. I can verify that it is correctly requesting that PHP file and the PHP file is returning data, as I can see it in the “Response” tab of Firebug.
I’ve also tried replacing the alert with document.write(data) and that doesn’t work either.
Can anyone lend a hand? I’m clueless.
You’re closing the call to
get()too early. The parenthesis after+ server_nameshouldn’t be there.should be
Just an aside but with jQuery’s ajax functions, you have the ability to pass an object for the data and jQuery will create the query string out of it, neatly escaping anything requires it. So you might do this which is equivalent to your original call for disable: