views:

1377

answers:

2

I'm writing an ASP.NET webforms app, and I'm using jQuery for my AJAX calls. This is working well, but on some occasions, the $.getJSON call is causing a full page postback. I am not using the ASP.NET AJAX library anywhere in the app. I can't reproduce the problem on a consistent basis, and am not sure what is causing it. Here is the jQuery code I am using. Anyone run across this before? Is is possible the previous AJAX call might not have completed, and requests are overlapping?

function getActionMismatch(id) {
    setPageElementVisibility();
    $(".ActionDetailArea").slideUp("fast");
    $("#AjaxLoader_Action").show();

    $.getJSON("Main.aspx?Callback=GetMismatch",
    { MismatchId: id },
    function(result) {
        $("#adMismatchId").text(result.MismatchId);
        $("#adAuthMerchId").text(result.AuthorizationMerchantId);
        $("#adSttlMerchId").text(result.SettlementMerchantId);
        $("#adCreateDate").text(formatJSONDate(Date(result.AppendDts)));

        $(".ActionDetailArea").slideDown('fast', toggleBlock('...click Adjust Promo to enter details', true));
        $("#AjaxLoader_Action").hide();
    }
    );
    return false;
}
A: 

Under some circumstances when jQuery can't do a AJAX call, so it creates a hidden iframe and does a normal submit from there. I'm guessing that some how that process is breaking down.

James Curran
But is there any other function I can use within getJSON to determine errors encountered or to determine when the call is complete?
Mark Struzinski
+1  A: 

How are you triggering that JavaScript function?

If it's a client-side click handler on a control like a Button, you need to be sure to call preventDefault(). Otherwise, the browser will submit the form and cause a postback, even while the AJAX callback is in progress.

Dave Ward