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

查看:26
本文介绍了如何更改 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) {

我想将 Accept 更改为 application/json

都不起作用.

推荐答案

在使用 JSONP 时无法控制浏览器发送的标头.JSONP 是一个聪明的技巧(或黑客,取决于你如何看待它......),它包括插入一个指向服务器端点的

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