1、js ajax 设置自定义header
1.1 方法一:
$.ajax({
type: "POST",
url: "Handler1.ashx",
contentType: "application/x-www-form-urlencoded",
beforeSend: function (request) {
request.setRequestHeader("token1", "Chenxizhang");
},
success: function (data) {
//your code
}
});
1.2 方法二:
$.ajax({
headers: {
"testheader": "test"
},
type: "POST",
url: "Handler1.ashx",
contentType: "application/x-www-form-urlencoded",
success: function (data) {
//your code
}
});