使用 jQuery 表单插件时设置标题 [英] Setting headers when using jQuery Form Plugin
本文介绍了使用 jQuery 表单插件时设置标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 JQuery 表单插件,但我不确定如何设置标题.
I'm using JQuery Form Plugin and I'm not sure how to set headers.
我希望能够完成这样的事情:
I want to be able accomplish something like this:
$.ajax({
url: "/url",
data: post,
type: "POST",
beforeSend: function(jqXHR) {
jqXHR.setRequestHeader("foo", "bar");
},
})
但是 beforeSubmit 事件不会传递 jqXHR 对象进行操作.有什么想法吗?
but the beforeSubmit event dosn't pass the jqXHR object for manipulation. Any ideas?
推荐答案
事实证明,options object 您发送到表单插件实际上将选项传递给 $.ajax 方法.因此,您可以使用原生的 before 发送功能.
As it turns out, the options object you send to the form plugin actually passes the options to the $.ajax method. Therefore you can use the native before send function.
这篇关于使用 jQuery 表单插件时设置标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文