jquery ajax请求时,设置请求头信息
设置一个名为 headers 的参数
参考代码:
// attempt to make an XMLHttpRequest to indeed.com // jQuery 1.6.1 and Chrome dev 13.0.767 function makeRequest() { alert("inside makeRequest()"); var settings = { type: "GET", url:URL+"?"+REQUEST, dataType:"xml", error: function(XHR,textStatus,errorThrown) { alert ("XHR="+XHR+"\ntextStatus="+textStatus+"\nerrorThrown=" + errorThrown); }, success: function(data,textStatus) { $("body").append(data); }, headers: { "Access-Control-Allow-Origin":"http://example.edu", "Access-Control-Allow-Headers":"X-Requested-With" } }; $.ajax(settings); }
posted on 2016-09-21 14:59 everest33 阅读(12269) 评论(0) 编辑 收藏 举报