0
我无法尝试将标题添加到我已有的同步方法中。我想我会把它们作为一个关键:对象,或者将它们设置为选项;这两种方法我看到在不同的职位。这两种尝试都不会在chromes网络选项卡或我的api日志中显示标题。主干同步,添加标题以同步
我也试图通过jquery的设置可全局设置此:
$.ajaxSetup({
headers: { 'x-my-custom-header': 'some value' }
});
任何帮助将不胜感激!
作为选项散列。
sync: function(method, model, options) {
options.headers = { 'X-Key-Whatever' :'Foobar' }
// Default JSON-request options.
var params = _.extend({
type: 'GET',
dataType: 'jsonp',
url: model.url(),
processData: false,
jsonpCallback: 'abcShowSomething',
cache: true
}, options);
// Make the request.
return $.ajax(params);
},
作为params键:
sync: function(method, model, options) {
// Default JSON-request options.
var params = _.extend({
type: 'GET',
headers: { 'X-Key-Whatever' :'Foobar' },
dataType: 'jsonp',
url: model.url(),
processData: false,
jsonpCallback: 'abcShowSomething',
cache: true
}, options);
// Make the request.
return $.ajax(params);
},