JQuery Ajax with multiple return values from ASP.NET

How can I return multiple values from JQuery.Ajax() in the success function ?I tried it: $.ajax( type: “POST”, url: “default.aspx/myFunction”, data: “”, contentType: “application/json; charset=utf-8″, dataType: “json”, success: function(msg) $(“#myDiv”).html(msg.a[0]); $(“#myDiv2″).html(msg.a[1]); });And here my ASP….

via Asp.Net Developed Tutorials » Search Results » ajax:

JQuery Ajax with multiple return values from ASP.NET

How can I return multiple values from JQuery.Ajax() in the success function ?
I tried it:
$.ajax(
type: “POST”,
url: “default.aspx/myFunction”,
data: “”,
contentType: “application/json; charset=utf-8″,
dataType: “json”,
success: function(msg)
$(“#myDiv”).html(msg.a[0]);
$(“#myDiv2″).html(msg.a[1]);

});And here my ASP.NET page:
_
Public Shared Function myFunction() As Array

Dim a() As String
a(0) = “value 1″
a(1) = “value 2″

Return a

End FunctionIt works just in unique return string, but array doesn’t work :(
………………………..

Change it to msg.d[0].
Wirting msg.a is completely wrong; the method’s return value has nothing to do with a variable name.
However, for security reasons, ASP.Net wraps the JSON object in a d property, so you need to write msg.d to access the array.
………………………..

I got the solution!
I just use msg.d[0] instead msg.a[0]

For more info: JQuery Ajax with multiple return values from ASP.NET

Asp.Net Developed Tutorials » Search Results » ajax

JQuery Ajax with multiple return values from ASP.NET

Share this post:

Related Posts

Leave a Comment