I use the following code to get json formatted data:
$.ajax({
type: "GET",
url: "MyService.svc/GetSomeData",
dataType: "text",
success: function (data, textStatus) {
alert("Test: " + data.toString());
},
error: function (xhr, textStatus, errorThrown) {
alert("Error: " + (errorThrown ? errorThrown : xhr.status));
}
});
Data successfully returns to this call, and it looks like this:
{"d":"test data"}
My guess was that I could access the data as follows:
var myData = data["d"];
However, this always returns "undefined". What am I missing to get one row of “test data” data?
source
share