jQuery ajax data.d 未定义

jQuery ajax data.d undefined

我正在尝试使用 Ajax 调用获取 CRM 数据。返回的数据带有 'd' 和 'result' 属性,但我无法在客户端获取它。它说 ajaxdata.d 未定义。

样本Ajax调用:

var context = Xrm.Page.context;
var serverUrl = context.getClientUrl();
var ODATA_ENDPOINT = context.prependOrgName("/xRMServices/2011/OrganizationData.svc");

var filter = "?&$select=cc_TypeID,cc_customentityId,cc_anotherAttribute&$filter=cc_TypeID eq '2'";

var odataUri = ODATA_ENDPOINT + "/cc_customentitySet" + filter;

console.log("odataUri: " + odataUri);

//Asynchronous AJAX function to Retrieve a CRM record using OData
$.ajax({
    type: "GET",
    contentType: "application/json; charset=utf-8",
    datatype: "json",
    url: odataUri,
    async: false,
    beforeSend: function (XMLHttpRequest) {
        //Specifying this header ensures that the results will be returned as JSON.            
        XMLHttpRequest.setRequestHeader("Accept", "application/json");
    },
    success: function (ajaxdata, textStatus, XmlHttpRequest) {
        //console.log("cc_campaignSynch.htm > ready > $.ajax success: " + data);

        debugger;

    },
    error: function (XmlHttpRequest, textStatus, errorThrown) {
        console.log("cc_campaignSynch.htm > ready > $.ajax error: " + XmlHttpRequest.responseText);
    }
});

返回的数据快照:

更新快照(JSON.parse 使用):

可能没什么,但尝试将 "datatype" 更改为 "dataType"

要强制 jQuery magic 工作并识别数据类型,请尝试用 HEADER: "Content-Type: application/json".

发回响应