Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

ajax $.get runs late after the loop !!

$
0
0

Hello

I have a a loop processing $.get statement inside it. The $.get returns value from controller function. as follows:

res = null;
for (key in data.Results) {
   var url = "/Search/Get_ManID?MakeName=Test";$.get(url, function (data) {
   res = data; // it will get some value , data = 148
}
alert(res);

It will alert null instead of the value that it will hold.

The issue is that the alert statement will run before the $.get function.

How can I control the order of code running.


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>