【发布时间】:2014-03-24 19:43:38
【问题描述】:
我正在尝试向使用“jsonp”dataType 的 jQuery AJAX GET 请求添加接受标头,但由于某种原因它无法正常工作。到目前为止,这是我的代码。
var e4json = JSON.stringify( {
"thomas_smith106" : "Daniel244",
"transaction_type" : "34",
"transaction_tag" : "902006933",
"authorization_num" : "ET4653",
"amount" : "15.75"
} );
$.ajax ({
url: "https://api.demo.globalgatewaye4.firstdata.com",
type: "GET",
headers : {
'accepts' : 'application/json'
},
data: e4json,
dataType: "jsonp",
success: function (response) {
alert('Successfuly called the e4 gateway api');
}
});
我尝试了多种方法,但似乎没有任何效果。我查看了jQuery 网站上的文档,但找不到任何好的示例。
这是我的请求标头得到的。我需要接受标头为“应用程序/json”。
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:_fd_session=d69310c5cd4a02a4700b5ba63f0d0c9b
Host:api.demo.globalgatewaye4.firstdata.com
Referer:http://localhost:8080/smart-two-site/customerinfo.html
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36
任何帮助都会很棒。谢谢!
【问题讨论】:
标签: jquery ajax get jsonp http-accept-header