This question already has answers here:
</div>
</div>
<div class="grid--cell mb0 mt4">
<a href="/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call" dir="ltr">How do I return the response from an asynchronous call?</a>
<span class="question-originals-answer-count">
(38 answers)
</span>
</div>
<div class="grid--cell mb0 mt8">Closed <span title="2015-03-19 12:18:58Z" class="relativetime">5 years ago</span>.</div>
</div>
</aside>
function getvalue(value) {
document.getElementById('<%= hdnPack.ClientID %>').value = "0";
var stdPack = 0;
alert("a");
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "test.aspx/GetStdSellingPack",
data: "{'Col1':'" + value+ "'}",
dataType: "json",
success: function (data) {
alert("b");
if (data != null) {
$(data).each(function () {
var values = data.d;
stdPack = values;
});
}
},
error: function (result) {
alert("Error");
}
});
alert("c");
return stdPack;
}
Am trying to execute this function Always returning zero , Actually what happening Alert(a) got Fired ,Then Alert (C) fired And Suddenly it goes to Alert(b). The result I would like to get In order, Alert(a) to execute first then Alert(b) followed by alert(c).Pl give me a solution .Thanks in Advance
</div>