使用下面的代码片段,我在AJAX中返回一个值,然后检查返回值。我遇到的问题是它返回" undefined"。
function LoadUserControl() {
var i;
$.ajax({
type: "POST",
url: "Form.aspx/Load",
data: "",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (r) {
alert(r.d);// I get values
var data = $.parseJSON(r.d);
var ProjectID = data.ProjectID;
alert(ProjectID );//undefined
for (i = 0; i < r.d.length; i++) {
paramList = "{'FieldTypeName':'" + data.FieldTypeName + "'}";
if (paramList == "TextBox") {
alert();
}
}
}
});
}