gpt4 book ai didi

javascript - 英特尔 xdk 数据库

转载 作者:行者123 更新时间:2023-12-03 07:53:27 28 4
gpt4 key购买 nike

嘿,我正在使用 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);

}

最佳答案

英特尔 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
}
});

关于javascript - 英特尔 xdk 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34902305/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com