How do I debug jquery AJAX calls?
Using pretty much any modern browser you need to learn the Network tab. See this SO post about How to debug AJAX calls.
Make your JQuery call more robust by adding success and error callbacks like this:
$('#ChangePermission').click(function() {
$.ajax({
url: 'change_permission.php',
type: 'POST',
data: {
'user': document.GetElementById("user").value,
'perm': document.GetElementById("perm").value
},
success: function(result) { //we got the response
alert('Successfully called');
},
error: function(jqxhr, status, exception) {
alert('Exception:', exception);
}
})
})
if you are using mozilla firefox than just install an add-on called firebug
.
In your page press f12 in mozilla and firebug will open.
go for the net
tab in firebug and in this tab go in the xhr
tab.
and reload your page.
you will get 5 options in xhr
Params
Headers
Response
HTML
and Cookies
so by going in response
and html
you can see which response you are getting after your ajax call.
Please let me know if you have any issue.
You can use the "Network" tab in the browser (shift+ctrl+i) or Firebug.
But an even better solution - in my opinion - is in addition to use an external program such as Fiddler to monitor/catch the traffic between browser and server.