function getThisFrame(frameId) {
var r;
$.ajax({
type: "POST",
contentType: "application/json",
url: "abcdefg.asmx/RetriveThis",
data: "{Id:" + Id + "}",
dataType: 'json',
success: function (result) {
return result.d
}
});
}
The return value is always "undefined"? How could I solve this? Thanks!
The data is surely no problem!
you are returning result.d to $.ajax() not to getThisFrame().
You need somekind of callback if you want to handle result.d somehow.
function getThisFrame(frameId, callback) {
var r;
$.ajax({
type: "POST",
contentType: "application/json",
url: "abcdefg.asmx/RetriveThis",
data: "{Id:" + Id + "}",
dataType: 'json',
success: function (result) {
if(typeof callback === 'function') callback.apply(this, [result.d]);
}
});
}
getThisFrame(5, function(data){
// do something with data.
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With