Troubleshooting jQuery AJAX call using Generic Handler in ASP.NET

≯℡__Kan透↙ 提交于 2019-11-30 23:22:33

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!