【发布时间】:2016-05-07 03:06:41
【问题描述】:
click here for error screenshot
我正在尝试通过浏览器的 Web 服务将数据插入数据库,但出现错误(屏幕截图)。
$("#signup").click(function () {
var radio = $('input[name="radio"]:checked').val();
var fullname = $("#fullname").val();
var email = $("#email").val();
var phoneno = $("#phoneno").val();
var password = $("#password").val();
var dataString = "{'Cust_Type':'" + radio + "','Contact_Name':'" + fullname + "','Contact_No':'" + phoneno + "','Email':'" + email + "','Password':'" + password + "'}";
if ($.trim(radio).length > 0 & $.trim(fullname).length > 0 & $.trim(phoneno).length > 0 & $.trim(email).length > 0 & $.trim(password).length > 0) {
$.post({
type: "POST",
url: "http://test.com/testWebservices/testservices.svc/mobilesignup",
dataType: "json",
data: dataString,
crossDomain: true,
cache: false,
beforeSend: function () { $("#signup").val('Connecting...'); },
success: function (data) {
if (data == "success") {
alert("Thank you for Registering with us! you can login now");
}
else if (data = "exist") {
alert("Hey! You alreay has account! you can login with us");
}
else if (data = "failed") {
alert("Something Went wrong");
}
}
});
} return false;
});
我正在使用 phonegap 从 broswer 调用服务 api(不工作),但是当我尝试从邮递员插件调用时,它工作并且数据已成功插入数据库。
【问题讨论】:
-
您的 js 文件是否托管在 Web 服务器(例如 IIS)上?
-
不。我正在使用 phonegap 创建 apk 文件..
-
网站 test.com 托管在哪个网络服务器中?
-
iis server.only 托管服务。
-
在真实设备上尝试,而不是在浏览器上。
标签: android ajax cordova cors phonegap-plugins