ios*_*eak 10 javascript ajax jquery uiwebview ios
我有一个基本的jQuery ajax函数来通过UIWebView记录用户.但是,由于某种原因,它在UIWebView中返回空白.它可以在我的计算机上使用移动游戏,Chrome和firefox.
这是我的代码:
$("#login_button").live('click',function() {
var serializeme = $("#login_form").serialize();
alert(serializeme);
$.ajax({
type: "POST",
url: "http://domain/location/process_login.php",
data: serializeme,
success: function(theRetrievedData) {
var thePlace = theRetrievedData.indexOf("?!?success?!?");
if (thePlace != -1) {
var theArray = theRetrievedData.split("?!?success?!?");
var theUrl = theArray[1];
$('#content').fadeOut(500);
setTimeout( function() {window.location = theUrl;}, 500 );
} else {
alert(theRetrievedData);
alert("no bueno");
}
}
});
});
Run Code Online (Sandbox Code Playgroud)
在theRetrievedData刚刚返回警觉空白.
请帮忙!
PS:如果您想尝试登录,该应用程序在应用程序商店中称为"Dudles"(它是免费的).您将从警报中收到空白消息.
你也可以发布你的PHP代码吗?
我重写了你写的代码,我将如何编写代码,看看我是否能发现任何错误,而且似乎没有任何错误.这是我到目前为止:
$(document.body).on('click', '#login_button', function () {
$.ajax({
type: "POST",
url: "http://domain/location/process_login.php",
data: $(this).closest('form').serialize(),
success: function (response) {
var delimiter = "?!?success?!?";
var isSuccessful = response.indexOf(delimiter) !== -1;
if (!isSuccessful) {
// handle error
return;
}
$('#content').fadeOut(500, function () {
location = response.split(delimiter)[1];
});
}
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2169 次 |
| 最近记录: |