Troubleshooting jQuery AJAX call using Generic Handler in ASP.NET

后端 未结 3 1437
你的背包
你的背包 2021-01-06 14:21

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

相关标签:
3条回答
  • 2021-01-06 15:18

    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.

    0 讨论(0)
  • 2021-01-06 15:23

    Inspect the browsers console for more details and set breakpoints in your callbacks (success, error)

    0 讨论(0)
  • 2021-01-06 15:23

    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!

    0 讨论(0)
提交回复
热议问题