设置一个名为 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+" textStatus="+textStatus+" errorThrown=" + 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); }