views:

110

answers:

1

Hi all, I am developed an web application in asp.net. In this application I have used jquery ajax for some pages. In this application, when I make two ajax call asynchrounoulsy that would not do as I expceted. what is happening is even the second ajax call finishes i can see the result when the maximum time out ajax call finished. I mean i can see the both results in the same time, not one by one.

for an example. I have 3 pages

1) main.aspx - for make two ajax request.

2) totalCount.aspx - to find the total count. (max it takes 7 seconds to return, as corresponding table contains 3 lak records)

3) rowCount.aspx - to find the row details. (max it takes 5 seconds to return result).

due to this scene, I have planed to make asyn call in jquery ajax in asp.net. here is my code...

function getResult() { getTotalCount(); getRows(); }

// it takes max 7 seconds to complete // as it take 7 seconds it should display second.( I mean after the rows dispaying) // but displaying both at the same time after the max time consuming ajax call completed. function getTotalCount() { $.ajax({ type : "POST", async : true, url : "totalCount.aspx?data1=" + document.getElementById("data").value, success : function(responseText) {
$("#totalCount").attr("value", responseText); } })
}

// it takes max 5 seconds to complete. // after finished, this should display first.( i mean before total count displays) // but displaying both at the same time after the max time consuming ajax call completed. function getRows() {
$.ajax({ type : "POST", url : "getrows.aspx?data1=" + document.getElementById("data").value, async : true, success : function(responseText) {
$("#getRows").attr("value", responseText);
} });
}

I would like to know, If there is any possible to make asyn call in jquery ajax in asp.net. I searched in net, I got some points that says we cannot do this in asp.net

ref link: http://www.mail-archive.com/[email protected]/msg55125.html

if we can do this in asp.net How to do that?

thanks r.eswaran.

+2  A: 

I'm not a asp.net developer but in general ajax terms I can explain this issue as given below

As ajax stands it is asynchronous, so you to expect the two request in some particular oder will not be wise.

The timings given by will be the time taken by the db server to execute some queries but there are more to the request like network traffic etc, so your assumption that 1 request will return before other is not correct.

Arun P Johny
but, why should return both result at the same time. if either one finishes first then it gets to display to it's corresponding control.I am very sure about the timing. So, surly I can say that, one should finishes first....
eswaran