What is the best method to troubleshooting a jQuery AJAX call with ASP.NET? The error function is getting called--I get the alert to popup that says \"Error\", but I don\'t
I tried putting in a return false to prevent a full page postback, but that didn't seem to work.
If the main problem is that clicking the button control causes a full post back instead of an asynchronous call to your handler, you can add this code anywhere inside your jQuery click event handler:
jQuery("#<%=BtnUCSSearch.ClientID %>").click(function(e) {
// Existing code
e.preventDefault();
})
This works rather than return false
to stop the browser's normal behavior for the button click.
Inspect the browsers console
for more details and set breakpoints in your callbacks (success
, error
)
first of all, take care with global variables in javascript, if is possible abandon this pratice.
Make sure requisition URL is correct and not return 404 error.
In jquery ajax data, use JSON.stringify().
And in the asp.net handler use the JavascriptSerializer.
If not work, run with the firebug console opened, or chrome console. It's very helpful!