Techsavy
asked on
JQuery help
Hi,
I have following script, and I want the user to see a loading message until the .each is complete. I can show that message on an existing div tag on an HTML page. How do I modify following JQuery function, so that the user sees that message and it disappeas once everything is loaded?
function GetLocations() {
$.getJSON('/_vti_bin/listd ata.svc/Ma sterSiteLi st?$select =PROPERTY, PROPERTYNA ME,PROPERT YLATITUDE, PROPERTYLO NGITUDE,PR OPERTYSTRE ETADDRESS, PROPERTYCI TYLOCALE,P ROPERTYSTA TEPROVINCE ,PROPERTYC OUNTRY,PRO PERTYZIPCO DE,StatusV alue', function (data) {
$.each(data.d.results, function (i, result) {
if (result.PROPERTYLATITUDE && result.PROPERTYLONGITUDE) {
var site = new VELatLong(result.PROPERTYL ATITUDE, result.PROPERTYLONGITUDE);
var siteShape = new VEShape(VEShapeType.Pushpi n, site);
var siteStatus = result.StatusValue
siteShape.SetCustomIcon(se tIcon(site Status));
siteShape.SetDescription(m whMap_setI temDescrip tion(resul t));
mwhMap_map.AddShape(siteSh ape);
}
});
});
}
Any help is appreciated,
I have following script, and I want the user to see a loading message until the .each is complete. I can show that message on an existing div tag on an HTML page. How do I modify following JQuery function, so that the user sees that message and it disappeas once everything is loaded?
function GetLocations() {
$.getJSON('/_vti_bin/listd
$.each(data.d.results, function (i, result) {
if (result.PROPERTYLATITUDE && result.PROPERTYLONGITUDE) {
var site = new VELatLong(result.PROPERTYL
var siteShape = new VEShape(VEShapeType.Pushpi
var siteStatus = result.StatusValue
siteShape.SetCustomIcon(se
siteShape.SetDescription(m
mwhMap_map.AddShape(siteSh
}
});
});
}
Any help is appreciated,
ASKER
Hi leakim971:
Thank you for the quick response. I tried this and it works fine but there is one caveat. Since .getJSON method happens asynchronously, the loading hides a little earlier before all the results are processed using .each.
Thank you for the quick response. I tried this and it works fine but there is one caveat. Since .getJSON method happens asynchronously, the loading hides a little earlier before all the results are processed using .each.
try to put the hide after the each
ASKER
Hi leakim 971,
Thank you again. I think that will not solve the problem either because .getJSON executes asynchrounously. Therefore i think, replacing .getJSON with .ajax with async = false would be a good solution to use your trick. will let you know. thanks again!
Thank you again. I think that will not solve the problem either because .getJSON executes asynchrounously. Therefore i think, replacing .getJSON with .ajax with async = false would be a good solution to use your trick. will let you know. thanks again!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$("#loadingDiv").show();
$.getJSON('/_vti_bin/listd
$("#loadingDiv").hide();
$.each(data.d.results, function (i, result) {
put this somewhere :
Open in new window