http://www.cnblogs.com/itjeff/p/6007181.html
jQuery Ajax可以通过headers或beforeSend修改request的HTTP headers,例如:
$.ajax({
url: "./test.php",
type: "POST",
headers: {
"Accept" : "text/plain; charset=utf-8",
"Content-Type": "text/plain; charset=utf-8"
},
/*
beforeSend: function(jqXHR, settings) {
jqXHR.setRequestHeader('Accept', 'text/plain; charset=utf-8');
jqXHR.setRequestHeader('Content-Type', 'text/plain; charset=utf-8');
},
*/
data: {"user" : "min", "pass" : "he"},
error: function(jqXHR, textStatus, errorThrown) {
//....
},
success: function(data, textStatus, jqXHR) {
//....
}
}
本文介绍如何使用jQuery的AJAX方法通过headers选项或beforeSend回调函数来修改HTTP请求头,包括设置Accept和Content-Type等关键头字段。

1568

被折叠的 条评论
为什么被折叠?



