移动应用 - 跨域AJAX [英] Mobile apps - Cross-domain AJAX

查看:102
本文介绍了移动应用 - 跨域AJAX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图设计一些在私人移动设备上分发的软件(Android,iOS等)。

I am trying to design some software to be distributed on private mobile devices (Android, iOS etc).

使用HTML / CSS / JavaScript编写软件,并使用类似 Sencha Touch PhoneGap 或类似软件。

I would like to write the software with HTML/CSS/JavaScript and use something like Sencha Touch, PhoneGap or similar.

软件需要写入设备上的本地数据库

The software needs to write to a local database on the device and when it gets connectivity, post the data (securely) to a remote database on a web server.

我相信我的问题会发布到网络服务器上的远程数据库数据到服务器。至于我可以告诉AJAX可以使用JSONP来请求数据跨域,但不发送数据(至少不使用POST方法)。

I believe my problem will be posting the data to the server. As far as I can tell AJAX can use JSONP to request data cross-domain, but not to send data (at least not with POST method).

可以这是使用JavaScript?也许Sencha Touch,PhoneGap或其他移动应用编译解决方案有本机存储和跨域发布方法?

推荐答案

p> JSONP技术上是一个黑客。如果您可以控制自己的网络服务, CORS 是实现跨域调用的正确方法。 这篇文章是解释如何在Web API中启用CORS支持的一篇很棒的文章。如果你使用一些其他技术开发你的web服务,你可以从互联网上获取大量的信息如何CORS启用它。

JSONP technically is a hack. CORS is the correct way to implement cross domain calls if you have control over your web service. This is a great post explaining how to enable CORS support in Web API. if you use some other technology for developing your web service, you can get tons of information from internet on how to CORS enable it .

这篇关于移动应用 - 跨域AJAX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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