var userId = window.localStorage.getItem("zicuserId");
var dataString = "deviceId="+myDeviceId + "&userId=" + userId + "&deviceToken=" + myDeviceToken;
alert("dataString: " + dataString);
$.ajax({
type: POST,
url: "http://mobilapps.zicoil.pk/fineName.php",
data: dataString,
async: false,
dataType: "text",
success: function(data)
{
window.localStorage.setItem("userDeviceRegister", "true");
alert(data);
},
error: function()
{
alert("error , you are in error function.")
}
});
答案 0 :(得分:1)
试试这个。
var userId = window.localStorage.getItem("zicuserId");
var dataString = {deviceId:myDeviceId,userId:userId,deviceToken:myDeviceToken};
alert("dataString: " + dataString);
$.ajax({
url: "http://mobilapps.zicoil.pk/fineName.php",
type: "POST",
data: dataString,
async: false,
dataType: "JSON",
success: function(data)
{
window.localStorage.setItem("userDeviceRegister", "true");
alert(data);
},
error: function()
{
alert("error , you are in error function.")
}
});
答案 1 :(得分:0)
此行中存在语法错误:type: POST,
。只需将POST
替换为"POST"
即可。这个参数应该是字符串,现在它不是定义变量。
BTW:您应该使用浏览器控制台来检测此类错误。