我使用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,如何重新加载页面重定向到浏览器?
发布评论