Skip to content

Instantly share code, notes, and snippets.

@chadwilcomb
Last active July 23, 2022 17:04
Show Gist options
  • Save chadwilcomb/c9ddf626883b3d0bd312 to your computer and use it in GitHub Desktop.
Save chadwilcomb/c9ddf626883b3d0bd312 to your computer and use it in GitHub Desktop.
Ajax switch case
switch(App.LocationSearchType) {
case 'map':
return false;
case 'stretch':
if (onB7SC && fromB7SC && toB7SC) {
doAjax = true;
url = globals.virtualName + '/Geosupport/GetStretchLocations/';
data = {
onStreetCode: onB7SC,
fromStreetCode: fromB7SC,
toStreetCode: toB7SC
};
}
break;
case 'block':
if (onB7SC && fromB7SC && toB7SC) {
doAjax = true;
url = globals.virtualName + '/Geosupport/GetBlockLocation/';
data = {
onStreetCode: onB7SC,
fromStreetCode: fromB7SC,
toStreetCode: toB7SC
};
}
break;
case 'address':
if (onB7SC && houseNum) {
doAjax = true;
url = globals.virtualName + '/Geosupport/GetAddressLocation/';
data = {
onStreetCode: onB7SC,
houseNum: houseNum
};
}
break;
case 'intersection':
if (onB7SC && fromB7SC) {
doAjax = true;
url = globals.virtualName + '/Geosupport/GetIntersectionLocation/';
data = {
onB7SC: onB7SC,
fromB7SC: fromB7SC
};
}
break;
}
if (doAjax) {
this.showLoading();
$.ajax({
url: globals.virtualName + '/Geosupport/GetIntersectionLocation/',
data: {
onB7SC: onB7SC,
fromB7SC: fromB7SC
},
success: function (data) {
_this.processResponse(data, specLoc, houseNum);
},
error: function (xhr) {
_this.hideLoading();
throw new Error(xhr.statusText);
}
});
} else {
this.hideLoading();
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment