I’m having a deferment issue that I wondering if there is a good way to handle
Here is my code:
getFullAddressFromId: function (contactId) {
var contact;
$.ajax({
url: "/WebServices/FormOverview.asmx/GetFullAddressfromId",
data: { id: contactId},
success: function (result) {
contact = result;
},
error: function (err) {
_local.sendNotification.apply(this, ['Failed to load address information', 'Error']);
}
});
};
return contact;
}
Problem here obviously is “contact” is not loaded by the time it hits the return statement as the webservice has not finished running.
How can I defer the return from this function (getFullAddressFromId) to wait for the webserbvice.
Use asynchronous programming techniques.
Or use deferred objects with jQuery 1.5+