JSON: Error Domain
JSON: Error Domain
当我尝试使用来自 PHP API 的信息时,我的请求中出现错误:
OPTIONS http://api.reddrummer.com/summary.json?api_key=tok 405 (Method Not Allowed) jquery.js:130
OPTIONS http://api.reddrummer.com/summary.json?api_key=tok Invalid HTTP status code 405 jquery.js:130
XMLHttpRequest cannot load http://api.reddrummer.com/summary.json?api_key=tok. Invalid HTTP status code 405
(tok 是我从 API 访问信息的令牌(
(function($){
document.addEventListener("deviceready", function(){
tok = window.sessionStorage.getItem("token");
jQuery.ajax({
type: 'GET',
url: 'http://api.reddrummer.com/summary.json?api_key=' + tok,
contentType: "application/json",
dataType: 'json',
success: function(d) {
alert("ok");
},
error: function(error){
alert("not ok");
}
});
}, false);
})(jQuery);
那是我的 ajax,所以我更改了 dataType 以接收 jsonp 而不是 json:
(function($){
document.addEventListener("deviceready", function(){
tok = window.sessionStorage.getItem("token");
jQuery.ajax({
type: 'GET',
url: 'http://api.reddrummer.com/summary.json?api_key=' + tok,
contentType: "application/json",
dataType: 'jsonp',
jsonpCallback: 'callback',
jsonp: false,
success: function(d) {
alert("ok");
},
error: function(error){
alert("not ok");
}
});
}, false);
})(jQuery);
现在还有另一个错误:
Uncaught SyntaxError: Unexpected token : summary.json:2
这是我的 json 中的一个错误,所以我已经验证了我的 json,没有任何问题:
{
"username": "Guilherme",
"language": "pt-br",
"position": "Java Pleno",
"company_name": "Reddrummer",
"photo": "http://drumcircle.reddrummer.com/p/photo/user/guiandmag@gmail.com",
"post": {
"total_post": "1",
"total_comments": "1",
"groups": 1,
"groups_url": {
".Delivery Brasil": "http://drumcircle.reddrummer.com/#houseorgan/2566054"
},
"people": 2
},
"chart": {
"_video": 0,
"_image": 0,
"project": 0,
"topic": 0,
"note": 0,
"mobile": 0,
"task": 0,
"press": 0,
"bug": 0,
"reuniao": 1,
"sap": 0,
"oracle": 0,
"sharep": 0,
"vendas": 0,
"ideia": 0
}
}
我需要一些帮助,因为我正在尝试查看文档和许多其他网站,但是当我尝试使用 JSONP 从我的 API 接收值时,错误总是相同的。
JSONP使得从另一个域请求服务/数据成为可能。格式与经典 JSON 对象略有不同。
服务需要将数据包装到回调函数中,并将其作为参数传递。这个回调通常是动态的,并作为查询字符串参数传递(即jQuery通过附加"callback"参数键自动执行(。
想象一下 jQuery $.ajax(( 调用的 URL http://api.reddrummer.com/summary.json?api_key=12345&callback=jQuery152031713143712840974_1378285818229&_=1378285824291
,服务需要返回:
jQuery152031713143712840974_1378285818229(
{
"username": "Guilherme",
"language": "pt-br",
"position": "Java Pleno",
"company_name": "Reddrummer",
"photo": "http://drumcircle.reddrummer.com/p/photo/user/guiandmag@gmail.com",
"post": {
"total_post": "1",
"total_comments": "1",
"groups": 1,
"groups_url": {
".Delivery Brasil": "http://drumcircle.reddrummer.com/#houseorgan/2566054"
},
"people": 2
},
"chart": {
"_video": 0,
"_image": 0,
"project": 0,
"topic": 0,
"note": 0,
"mobile": 0,
"task": 0,
"press": 0,
"bug": 0,
"reuniao": 1,
"sap": 0,
"oracle": 0,
"sharep": 0,
"vendas": 0,
"ideia": 0
}
}
);
相关文章:
- jQuery Error adadvisor.net
- Ajax调用ERror Cross Origin REquest:在rails中自动完成大学列表
- 类型error primeFactors.for不是函数
- Array.every返回false,而不是类型error
- datatables.net ajax error - http://datatables.net/tn/7
- Cross domain - REST API
- Error: timers.js:234 callback.apply(timer, args);
- 滚动到错误字段ERROR
- Error with xmlhttpresponse
- ajax javascript 500 error
- 将数据从ExpressJS发送到AngularJS ERROR json
- walkscore API JSON error
- STRIPE.JS Error
- 对这种与document.domain和CORS相关的不一致行为的解释是什么
- Angular Routing Pretty URL Error
- 节点回调参数无法断言instanceof Error
- Jasmine .calls.count and .calls.any throwing error
- React.render error
- 如何访问npm模块抛出的自定义错误对象[error:[object object]]
- JSON: Error Domain