0

I kept one function in $.each() function and sending an array of elements to that function by using $.each() function. But the $.each() function doesn't care about the function and itself running.

Please solve my problem

This is the code

$.each(addrArray, function(i, item) {
    alert(addrArray[i].ActualAddress);
    getLatLang(addrArray[i].ActualAddress, addrArray[i].BusinessEntityID);
   });
Edukondalu Thaviti
  • 575
  • 1
  • 5
  • 16

2 Answers2

1

Assuming that you have Ajax call written in getLatLang() function; i will suggest to make that Ajax call synchronous like follows:

$.ajax({
        url: 'your url for getting lat-long',
        type: 'POST',
        data: {your address},
        async: false,
        success: function() {}
      });

Here async: false will do the job. Your program execution will remain in this function till the time you get back your lat-long from server. Once returned from this function; your .each loop will get incremented.

vijayP
  • 11,432
  • 5
  • 25
  • 40
0
each(function() {
if (something) 
return false;
});

For Documentation : Link

Anand Dwivedi
  • 1,452
  • 13
  • 23