【问题标题】:Intel xdk Database英特尔 xdk 数据库
【发布时间】:2018-05-21 15:52:27
【问题描述】:

嘿,我正在使用 Intel xdk 开发混合应用程序。在那我创建了注册表然后我把代码放在那里。在我尝试使用 Php Mysql 将我的数据库插入我的数据库之后。

如果我单击注册按钮,它会显示如下错误 [Cannot POST /http-services/emulator-webserver/ripple/userapp/xC/Users/System-5/AppData/Local/XDK/xdk-scratchdir/8167921a-fe37 -4721-a49c-7e81a19997af/platforms/android/assets/www/index.html]

我的 html 代码:

<form method="post" action="registration.php">

<input name="username" type="text" placeholder="Username" id="name" />
<input name="password" type="password" placeholder="Password" id="password" />
<input name="confirmpassword" type="password" placeholder="Confirm Password" id="confirmpassword" />
<input name="email" type="text" placeholder="Email" id="email" />
<input name="phonenumber" type="text" placeholder="Phone number" id="phonenumber" />
<input name="submit" type="submit" value="Register"/>

</form>

我的 Javascript 代码:

function signUp(){
    var credsArr = {};
    credsArr["username"] = document.myform.username.value;
    credsArr["password"] = document.myform.password.value;
    credsArr["email"] = document.myform.password.value;
    credsArr["phonenumber"] = document.myform.password.value;
    var xmlhttp = new XMLHttpRequest();
    var url = "http://127.0.0.1:58889/phonegap/registration.php?username=" + credsArr["username"] + "&password=" + credsArr["password"] + "&email="+credsArr["email"] + "&phonenumber="+ credsArr["phonenumber"];
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            myFunction(xmlhttp.responseText);
        }  else if (xmlhttp.status == 404) {
            intel.xdk.notification.alert("Web Service Doesn't Exist!", "Error");
        }
    };
    xmlhttp.open("POST", "http://127.0.0.1:58889/phonegap/registration.php", false);
    xmlhttp.send();
    function myFunction(response) {
        var arr = JSON.parse(response);
        if (arr.success == 1) {
            intel.xdk.notification.alert("Registered successful!");
        } else {
            intel.xdk.notification.alert(arr.success + " " + arr.message);
        }
    }  
    return(true);

} 

【问题讨论】:

  • web服务器上是否安装了php?
  • 是的,我在我的服务器上安装了 php

标签: javascript html


【解决方案1】:

英特尔 XDK 将引入一个 jquery 库。

将您的网络服务调用更改为:

 var url = "http://127.0.0.1:58889/phonegap/registration.php";

    var JSONObject= {
         "username":credsArr["username"],
         "password":credsArr["password"],
         "email:":credsArr["email"],
         "phonenumber:":credsArr["phonenumber"],
    };

    $.ajax({
        url: url,
        type: 'GET',
        data: JSONObject,
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        success: function (arr) {
           //do something
        },
        error: function () {
          //do something  
        }
    });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-23
    • 1970-01-01
    • 1970-01-01
    • 2017-08-14
    相关资源
    最近更新 更多