I have the following C# webservice (for testing purposes), which I eventually will turn into a WCFWebservice.
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[ScriptService]
public class Albums : WebService {
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public Person GetPeople() {
return new Person("Mike", 12);
}
}
And I call this using the following js:
$(document).ready(function () {
$.ajax({
url: '/webservice/Albums.asmx/GetPeople',
contentType: "application/json; charset=utf-8;",
dataType: "json",
type: 'post',
success: function (data) {
console.log(data);
}
});
});
But the weird thing (to me) is, I can't access data.Name
within success()
.
Somehow, it adds a object d
to data
.
So if I want to access the name, I need to use: data.d.Name
.
Where does this d
come from?