Javascript Ajax条件在jquery mobile phonegap中不起作用

Javascript Ajax条件在jquery mobile phonegap中不起作用,javascript,Javascript,在Ajax中,用于检查readystate和status的条件在jquerymobilephonegap中不起作用。我通过在条件中提供一条警告消息来检查它。为什么?我附上了密码 function checkLogin() { // navigator.notification.alert("hiii"); var username; var password; var x=new XMLHttpRequest(); x.onreadystatechan

在Ajax中,用于检查readystate和status的条件在jquerymobilephonegap中不起作用。我通过在条件中提供一条警告消息来检查它。为什么?我附上了密码

 function checkLogin()
{
   // navigator.notification.alert("hiii");

    var username;
    var password;

    var x=new XMLHttpRequest();
    x.onreadystatechange=function()
    {

       // alert("....."+x.responseText);
        if (x.readyState == 4 && x.status == 200)
        {
            // alert(x.readyState+"  --- "+x.status);
            alert("hai checkLogin");
            var item=x.responseText.trim();
            alert("Message :"+item);

            if(item=="1")
            {
                window.location="home.html";
            }
        }
    }

    //alert("open");
x.open("POST", "http://localhost:8087/CarRental/com/selcar/getLogin.jsp?username="+document.getElementById('username').value+"&password="+document.getElementById('loginpaswrd').value, true);
x.send();

您还没有使用
x.send()
启动请求,也没有使用任何http方法,如get、post为什么不使用fetch?您需要IE11支持吗?如果是的话,请使用polyFill。对不起,我不知道如何使用fetch。你能解释一下吗?