如何在有角度的$http服务请求中将JSONP指定为dataType
How do I specify JSONP as the dataType in an angular $http service request?
我熟悉使用jQuery的$.ajax
:
$.ajax({
url: //twitter endpoint,
method:"GET",
dataType:"jsonp",
success:function() {
//stuff
}
});
如何为角度$http
服务请求指定JSONP
数据类型?
到目前为止,我已经尝试过这个:
$http.get({
url: //twitter endpoint,
dataType: "jsonp",
success: function(){
//stuff
}
});
但它没有起作用。有什么想法吗?
您可以始终使用$http.jsonp(url).success(function() {} );
$http.jsonp
试试这个:
$http({
method: 'JSONP',
url: '/someUrl?cb=JSON_CALLBACK'
}).then(function (response) {
// stuff
});
相关文章:
- JSONP请求返回结果,但也触发error_callback
- 在localhost Dev Box上测试JSONP请求的最佳方式
- 正在传递JSONP标头's数据参数到另一个文件中的AJAX请求
- 成功回调永远不会被JSONP请求调用
- 向Yahoo Finance API发出JSONP请求时获得400错误请求
- 响应 JSONP 请求时循环的无限空的目的是什么
- 无法向谷歌搜索网页发出JSONP请求
- JavaScript JSONP请求错误--未捕获的语法错误:意外的令牌:
- AngularJS http.jsonp请求.then和.success函数不起作用
- 使用jQuery进行跨域ajax JSONP请求
- ajax jsonp请求503响应
- Ajax get jsonp给出错误代码500“;请求被阻止”;来自MVC应用程序
- 如何在有角度的$http服务请求中将JSONP指定为dataType
- 跨域AJAX请求返回HTML(不是jsonp)
- JSONP 在 IE10 中不适用于跨域请求
- 使用 jsonp 的跨域请求:从 https 到 http
- 请求 JSONP 时的文本/html 输出
- 请求jsonp和Uncaught SyntaxError:意外token:
- 请求JSONP GeoServer的多个AJAX调用
- 如何在Javascript成功请求JSONP后正确打印JSON对象