[英]error 400 bad request with AJAX form
JS: JS:
function submitForm(){
var data = {
name: _("#name").value,
email: _("#email").value,
message: _("#message").value
}
var output = JSON.stringify(data);
var ajax = new XMLHttpRequest();
ajax.open( "POST", "/src/scripts/parser.php" );
ajax.setRequestHeader("Content-Type", "application/json'");
ajax.onreadystatechange = function() {
if(ajax.readyState == 4 && ajax.status == 200) {
console.log('success')
} else {
console.log('fail')
}
}
ajax.send( output );
console.log(output)
} }
When im trying submit form, i have error: 当我尝试提交表格时,我遇到了错误:
400 Bad Request Your browser sent a request that this server could not understand. 400错误的请求您的浏览器发送了此服务器无法理解的请求。
Can somebody help me? 有人可以帮我吗? Thanks anyway :) 不管怎么说,还是要谢谢你 :)
The key here is this statement: 'that this server could not understand'. 此处的关键是以下语句:“该服务器无法理解”。 This usually indicates that something is wrong on the server. 这通常表明服务器上有问题。 But it could also be that your url is wrong. 但是也可能是您的网址错误。 Either... 要么...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.