`
FZtree
  • 浏览: 105975 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

javascript/jquery读取和修改HTTP headers

 
阅读更多

http://www.cnblogs.com/itjeff/p/6007181.html

 

jQuery Ajax可以通过headersbeforeSend修改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) {
            //....
        }
    }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics