I have the following code
$(function() {
$('.apply').click(function(e) {
var z = $(this).attr('z-id');
var r = $(this).attr('r-id');
$.post(
"/r-set-z",
"z_id=" + z + "&r_id=" + r,
function(data) {
alert(data);
}
);
});
});
It works correct except that i see no alert with response data. Everything on server goes well. All data processing there done every time I click corresponding button. The data returning by the server is of type application/javascript and consist of the following
{"msg": "save successful"}
Why there is no alert after clicking a button?
Try returning the response from the server as
application/jsonand either specify JSON in your$.post:Or use
$.getJSON