Coffeescript 语义用户界面/搜索-自定义HTTP\U接受
我正在做一个带有语义ui的搜索模块,我需要为我的结果调用一个json:API格式的API。因此,我需要在HTTP_accept头中接受“application/vnd.api+json”。 在发送ajax请求之前,是否有方法使用回调重载标头Coffeescript 语义用户界面/搜索-自定义HTTP\U接受,coffeescript,semantic-ui,json-api,Coffeescript,Semantic Ui,Json Api,我正在做一个带有语义ui的搜索模块,我需要为我的结果调用一个json:API格式的API。因此,我需要在HTTP_accept头中接受“application/vnd.api+json”。 在发送ajax请求之前,是否有方法使用回调重载标头 $('.ui.search') .search({ type: 'recipe', apiSettings: { onRequest: (promise, xhr) -> xhr.
$('.ui.search')
.search({
type: 'recipe',
apiSettings: {
onRequest: (promise, xhr) ->
xhr.setRequestHeader('HTTP_ACCEPT', 'application/vnd.api+json')
url: '//staging-doeat.herokuapp.com/api/v1/recipes',
onResponse: (response) ->
console.log(response)
},
});
我想做这样的事情。但它不起作用
谢谢你的回复