我发送跨域ajax请求,另一端request.is_ajax()
发送False
var text = getSelectedText();
text = 'text';
if (text){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(this.responseText)
}
};
xhttp.open("GET", "http://example.com/text=" + encodeURIComponent(text), true);
xhttp.send();}
答案 0 :(得分:5)
您将手动添加它(如jQuery和其他库一样):
xhttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest');