我是jquery新手,想了解response和response.d之间的区别是什么,我在故障警报中使用response.d。
我想知道如果发生故障,在消息框中将显示什么警报(respose.d)。
下面是我的代码
$.ajax({
type: "POST",
url:"Abc.aspx/Function1",
data: '{MonthDateID: ' + $('#<%=ddlMonth.ClientID%>').val() + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: Function2,
failure: function(response) {
alert(response.d);}});
Run Code Online (Sandbox Code Playgroud)
如有任何查询,请告诉我
回应永远是对象。为了获取数据,您必须使用response.d。
如果您仅在警报中添加响应,它将显示类似[Object]警报中的内容。
假设response包含一条消息“成功完成Ajax调用”,然后查看该消息,您必须使用response的response.d(“ d”)属性。