简体   繁体   English

从PhoneGap Android连接到Java服务器

[英]Connecting from phonegap android to java server

We have a server written in java, and an application written in phonegap for the android with javascript. 我们有一个用Java编写的服务器,一个用phonegap编写的应用程序,用于使用javascript的android。

How can we transfer and receive information from the application to the server? 我们如何从应用程序向服务器传输和接收信息? We've tried using DWR to no avail, as the html file is on the android, so we can't call methods on the server. 我们尝试使用DWR无济于事,因为html文件位于android上,因此我们无法在服务器上调用方法。

Is there anyway around it so we can use DWR or another method to contact the server? 无论如何,我们可以使用DWR或其他方法与服务器联系吗?

Thanks 谢谢

We transfer and receive information by using AJAX calls and jQuery, and setting the server headers correctly (ie, setting "Access-Control-Allow-Origin" to "*"). 我们使用AJAX调用和jQuery传输和接收信息,并正确设置服务器头(即,将“ Access-Control-Allow-Origin”设置为“ *”)。 This allows any client to make cross-domain AJAX calls. 这允许任何客户端进行跨域AJAX调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM