简体   繁体   English

错误400错误的AJAX表单请求

[英]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... 要么...

  1. parser.php does not exist parser.php不存在
  2. parser.php exists in a different folder (other than 'src/scripts') parser.php存在于其他文件夹中(“ src / scripts”除外)
  3. There is a url re-write module on the server that obfuscates the physical path of parser.php 服务器上有一个url重写模块,混淆了parser.php的物理路径
  4. parser.php returns a 400 error parser.php返回400错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM