我正在将 jqMobi 框架用于 Web 应用程序。在我的应用程序中,我连接到服务器,发送用户名和密码并收到如下字符串:
[{"utoken":"e43aa84cc304a1ed3722832616294516b118a5c2","username":"myusername","sharecode":"testmus","created":"2012-07-17 13:51:32"}]
我得到了回应,但随后它停止了。
我的代码是:
function Connectserver() {
var form = $("#loginForm");
//disable the button so we can't resubmit while we wait
$("#submitButton",form).attr("disabled","disabled");
var u = $("#username", form).val();
var p = $("#password", form).val();
alert('knappen bliver klikket') ; //This fires
if(u != '' && p!= '') {
alert('data sendes') ; //This fires
$.post("http://m.myhost.com/service/login.php", {username:u,password:p}, function(data) {
alert('renspons retur') ;//This are not fired
if(data[0].username == u) {
//store
alert('renspons retur') // Not fired
var utoken = data[0].utoken;
localStorage.setItem("utoken", utoken);
}
else
{
alert("Dine loginoplysninger er ikke korrekte", function() {});
}
$("#submitButton").removeAttr("disabled");
},"json");
} else {
alert("Du skal indtaste brugernavn og password", function() {});
$("#submitButton").removeAttr("disabled");
}
return false;