Calling a web Method that returns a non String by AJAX [ASP.net]-Collection of common programming errors
i made a web function in the C# file called test
it returns a simple List for testing
[WebMethod(EnableSession = false)]
public static List test()
{
List a = new List () ;
a.Add("1s");
a.Add("2s");
return a;
}
i tried to call this WEBMETHOD
from the front end using JQUERY AJAX
function Test() {
$.ajax({
type: "POST",
url: "Default.aspx/test",
data: "",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
x = msg;
$(".resultbox").html(msg.d);
}
});
return x;
}
when i call test() ; from the console the message was :
Uncaught Error: NOT_FOUND_ERR: DOM Exception 8 jquery-1.6.1.min.js:18
in common cases i convert objects into JSON and return them and this usually work but i’m interested to know how objects are returned from the WEBMETHOD to the front end are they serialized into text , why did this error happened .