tags:

views:

1178

answers:

2

Scenario: Within the onblur event of a html input control I send an async http post to a resource i.e. t.aspx.

I do not care if it ever returns, however if the users clicks submit I want the form to submit.

What I am seeing from using our simulators is that when I slow down t.aspx to take 10 seconds (page_load Thread.Sleep(10000)) when I click submit it continues to wait for the remainder of the 10 seconds and then submits.

I need the form to submit straight away. Below is a snippet of the ajax code

var _requestData = "{ " + "\"subject\": { " + "\"param1\": \"" + $("#param1").val() + "\", " + "\"param2\": \"" + $("#param2").val() + "\" " + "}" + " }";

$.ajaxSetup({ url: "t.aspx", type: "POST", processData: false, contentType: "application/json", dataType: "json", success: sucessfulCallback, error: unsucessfulCallback });

$.ajax({ data: _requestData });

I have also tried var myAjax = $.ajax ..... and calling myAjax.abort() within the form submit. No luck there either.

Any help would be much appreciated...

Regards David

A: 

You don't mention which Jquery version you are running. Older versions had a known bug which is exactly as you describe: http://dev.jquery.com/ticket/2935.

Douglas F Shearer
Using jquery v1.3.2
A: 

At Server side, you need to check user still connect with server or not. By using the following command.

if (!Response.IsClientConnected)
{
   // process user request
}
Soul_Master