In the following, the return
statement is being executed before the call to $.get()
finishes. How can I change this?
var aft = {};
aft.getToken = function (url) {
var theToken;
//Get the token value
$.get(url, function (data) {
theToken = $(data).find('input[name=__RequestVerificationToken]').val();
}, "html");
return theToken;
};
See Question&Answers more detail:os