【发布时间】:2011-07-29 13:14:51
【问题描述】:
我已将所需的元标记添加到我的网络应用程序中,以便它可以从没有 safari 元素(地址栏等)的跳板在 iPhone 上启动。 但是,我的登录页面通过 JS 工作,响应以 JSON 形式返回。
在 Safari 中,当不作为 Web 应用程序启动时,重定向工作正常(使用 window.location)。 当作为 Web 应用程序启动时,重定向似乎无法正常工作。屏幕将刷新,但在同一页面上。
这是网络应用程序的限制还是(我怀疑)我做错了?
这是响应ajax帖子的代码
genericPost: function (f, ajaxLoad) {
if (ajaxLoad == undefined)
ajaxLoad = true;
var form = $(f);
var data = form.serialize();
var action = form.attr("action");
$.ajax({
type: 'POST',
url: action,
data: data,
success: function (response) {
if (response.worked) {
//navigate to the next required page
//Notify.showMessage(response.message);
if (response.redirect) {
if (ajaxLoad) {
Notify.showMessage(response.message, "ok");
var back = response.direction == "back";
$.mobile.changePage(response.redirect, "slide", back, true);
}
else {
window.location = response.redirect;
}
}
else {
Notify.showMessage(response.message, "ok");
}
}
else {
Notify.showMessage(response.message, "error");
}
},
dataType: "json",
error: function () {
Notify.showMessage("Could not submit your form at the time. Please try again. Please try again", "error");
}
});
}
谢谢
【问题讨论】:
标签: javascript iphone web-applications