He creado un código JQuery AJAX utilizando algunos tutoriales que encontré en Internet. Soy nuevo en jQuery y quiero aprender cómo hacer las cosas mejor. Tengo un compañero de trabajo que creó una hermosa aplicación web utilizando una gran cantidad de jQuery.¿Por qué necesito usar .d para acceder a los datos devueltos por jQuery AJAX?
Lo que más me causa confusión aquí es: ¿por qué es necesario utilizar la ".d" cuando se refiere a la respuesta de mi método web y qué significa?
// ASP.net C# code
[System.Web.Services.WebMethod]
public static string hello()
{
return ("howdy");
}
// Javascript code
function testMethod() {
$.ajax({
type: "POST",
url: "ViewNamesAndNumbers.aspx/hello",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
alert(msg); // This doesn't display the response.
alert(msg.d); // This displays the response.
} // end success:
}) // end $.ajax