Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 阿贾克斯没有成功_Jquery_Ajax - Fatal编程技术网

Jquery 阿贾克斯没有成功

Jquery 阿贾克斯没有成功,jquery,ajax,Jquery,Ajax,我正在尝试使用Ajax进行表单验证,所以到目前为止我得到了以下结果: $.ajax({ type: "POST", url: "../includes/loginSystem.php", data: "username=" + username + "&password=" + password, beforeSend: function () { alert("LOADING....

我正在尝试使用Ajax进行表单验证,所以到目前为止我得到了以下结果:

        $.ajax({
        type: "POST",
        url: "../includes/loginSystem.php",
        data: "username=" + username + "&password=" + password,
        beforeSend: function () {
            alert("LOADING....");
        },
        success: function (html) {
            alert("success!");
            if (html.split(",")[0] == "true") {
                sessionStorage.setItem("loggedIn", true);
                loginEr.html("null");
                alert("true!");
                $("#login-modal").modal("hide");
                $("#navbar-nav2").html("<button id='profileBtn5' class='btn btn-default' data-toggle='modal' data-target='#profile-modal'><?php echo " + html.split(",")[1] + "; ?></button>")
            } else if (html.split(",")[0] == "false") {
                sessionStorage.setItem("loggedIn", false);
                loginEr.html(LOGIN_FAIL);
                alert("false!");
            }
        }
    });
$.ajax({
类型:“POST”,
url:“../includes/loginSystem.php”,
数据:“username=“+username+”&password=“+password,
beforeSend:函数(){
警报(“装载…”);
},
成功:函数(html){
警惕(“成功!”);
if(html.split(“,”[0]=“true”){
setItem(“loggedIn”,true);
html(“空”);
警惕(“真的!”);
$(“#登录模式”).modal(“隐藏”);
$(“#navbar-nav2”).html(“”)
}else if(html.split(“,”[0]=“false”){
sessionStorage.setItem(“loggedIn”,false);
html(登录失败);
警告(“错误!”);
}
}
});
有什么问题吗?因为它总是在发送前向我显示内容,对成功没有任何影响。

正确的答案应该是:

...
data: {username: username, password: password},
...

你的浏览器是怎么说的?你在js开发者工具的“网络”选项卡中看到了什么,或者在服务器的日志文件中看到了关于传入连接的任何内容吗?没有,我没有看到任何内容…GreenCube,您是否尝试为ajax实现错误/失败函数,并查看服务返回的结果?OP的
数据:
对象是序列化的,并且在语法上是有效的。