我正在发送一个 ajax 请求以使用 jsonp 从 salesforce 检索数据,但 jsonp 回调数据返回未定义
我的ajax请求是,
$j.ajax({
type: "POST",
async: this.asyncAjax,
url: "https://na14.salesforce.com/services/data/v26.0/
sobjects/customobject?callback=mycallback",
contentType: 'application/json',
cache: false,
processData: false,
data: payload,
jsonp: false,
jsonpCallback: function(data, textStatus, jqXHR){
alert('Data is '+data);
alert('Text status is '+textStatus);
alert('jqXHR is '+jqXHR);
},
error: (!this.refreshToken || retry ) ? error : function(jqXHR, textStatus, errorThrown) {
if (jqXHR.status === 401) {
that.refreshAccessToken(function(oauthResponse) {
that.setSessionToken(oauthResponse.access_token, null,
oauthResponse.instance_url);
that.ajax(path, callback, error, method, payload, true);
},
error);
} else {
error(jqXHR, textStatus, errorThrown);
}
},
dataType: "jsonp",
beforeSend: function(xhr) {
if (that.proxyUrl !== null) {
xhr.setRequestHeader('SalesforceProxy-Endpoint', url);
}
xhr.setRequestHeader(that.authzHeader, "OAuth " + that.sessionId);
xhr.setRequestHeader('X-User-Agent', 'salesforce-toolkit-rest-javascript/' + that.apiVersion);
if (that.userAgentString !== null) {
xhr.setRequestHeader('User-Agent',that.userAgentString);
}
}
});
但是,我得到的回应是,
Data is undefined.
Text status is undefined.
jqXhr is undefined.
我该如何解决这个问题?该ajax请求的格式是否正确?
谢谢