如何更改标头angularjs $ http.jsonp [英] how to change the headers for angularjs $http.jsonp

查看:189
本文介绍了如何更改标头angularjs $ http.jsonp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读文件

但我想我一定是误会了吧。

but I think I must have misunderstood it.

$http.defaults.headers.jsonp = { 'Accept' : 'application/json'};
$http.jsonp(url).success(function(data, status, headers, config) {

我也试过

$httpProvider.defaults.headers.jsonp = { 'Accept' : 'application/json'};
$http.jsonp(url).success(function(data, status, headers, config) {

我想改变接受应用程序/ JSON

无论是工作。

推荐答案

有没有办法控制,同时使用JSONP通过浏览器发送头。 JSONP是一个聪明的把戏(或黑客攻击,这取决于你怎么看......)那由插入&LT的;脚本> 标记指向的服务器端点。最终,它是一个浏览器谁将会同时通过请求脚本,头决定发送<脚本方式> 标签,你不能影响它

There is no way to control headers sent by a browser while using JSONP. JSONP is a smart trick (or a hack, depending on how you see it...) that consist of inserting a <script> tag pointing to a server endpoint. Ultimately it is a browser who will decide which headers to sent while requesting scripts via <script> tag and you can't influence it.

此处了解详情:修改的HTTP标头JSONP申请

这篇关于如何更改标头angularjs $ http.jsonp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆