http重定向与cordova,如何重新加载页面重定向到浏览器? [英] http redirect with cordova, how do I reload the page redirected to by the browser?

查看:260
本文介绍了http重定向与cordova,如何重新加载页面重定向到浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用cordova部署我的服务器 - 客户端应用程序。
提交表单后,服务器可能会重定向客户端:302重定向和所有。
在这种情况下,应用程序尝试从服务器加载页面,而不是自己的内存。

I'm using cordova to deploy my server-client app. After submitting a form, the server may redirect the client: 302 redirect and all. In this case, the app tries to load the page from the server instead of its own memory.

我正在寻找一个解决方案。要重申,我希望应用程序加载从自己的文件系统重定向到的文件。

I'm looking for a solution to this. To reiterate, I want the app to load the file it's being redirected to from its own file system.

我想到的是这样的:
我使用jquery提交所有表单并捕获这些重定向。

What I have in mind is something like this: I submit all forms using jquery and catch those redirects.

$.ajax({
    url : address,
    type : type, 
    data : values,
    statusCode: {
        302 : redirect_302
    }
})

然后捕获重定向并使用

redirect_302 function(response){
    window.location = the url in the response from the server
}

这是一个典型的解决方案吗?
或者有更好/更简单的选项吗?
也许我可以在sych中发出重定向,cordova不会,默认情况下,尝试从服务器加载页面?

Is that a typical solution? Or are there better/simpler options? Maybe I can issue the redirect in sych a way that cordova will not, by default, try to load the page from the server?

提前感谢。

Jenia

推荐答案

选项是做你正在做的事。让服务器返回正确的重定向,不太可能是因为它是一个文件或从服务器加载文件。

The options are to do what you are doing. Have the server return the proper redirect, unlikely since it is a file or load the file from the server.

重定向包含一个网址,应用程序被告知使用服务器所以没有任何东西自动为cordova做。

The redirect contains a url that the application is told to use by the server so there isn't anything automatic for cordova to do.

这篇关于http重定向与cordova,如何重新加载页面重定向到浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆