的Visual Studio 2015年科尔多瓦Apache服务器端 [英] Visual Studio 2015 Server side with Cordova Apache

查看:310
本文介绍了的Visual Studio 2015年科尔多瓦Apache服务器端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望这个问题是具体的。

I hope this question is concrete.

我想创建一个跨平台的移动应用程序。为了做到这一点我已经决定,我可能会使用,将支持的Apache科尔多瓦的IDE。我已经决定我可能会使用Visual Studio 2015年附加工具对于Apache科尔多瓦。

I want to create a cross-platform mobile application. In order to do so I have decided I will probably use an IDE that will support Apache Cordova. I have decided I will probably use Visual Studio 2015 with Additional Tools For Apache Cordova.

主要关注的我已经是对服务器端的连接,我需要在我的应用前景。我有我想通过这个应用程序访问某些MS-SQL表。据我的理解,Apache的科尔多瓦项目只包括纯JS和HTML。在过去,我已经使用ASPX / ASMX扩展,以便和我的数据库进行通信。是否有其他选择吗?或者,我可以只使用一个Apache科尔多瓦项目中历久弥新的ASMX Web服务,它仍然可以工作的跨平台?

The main concern I have is regarding the server side connection I need to have in my future application. I have some MS-SQL Tables that I want to get access to via this application. As far as I understood, Apache Cordova projects consist only pure JS and HTML. In the past I have used ASPX/ASMX extensions in order to communicate with my database. Is there an alternative? Or can I just use the good old ASMX Web Service inside an Apache Cordova project and it will still work cross-platform?

感谢就此事的任何光芒!

Thanks for any light on that matter!

推荐答案

您说得对,

的Apache Cordova / PhoneGap的项目只包括纯JS和HTML(和
  CSS)

Apache Cordova/Phonegap projects consist only pure JS and HTML (and CSS)

科尔多瓦/ PhoneGap的是只是一个包装,它包装在一个容器中的网页,并提供必要的API与设备的功能进行通信。

Cordova/Phonegap is just a wrapper, it wraps your page in a container and provide the necessary APIs to communicate with the device's features.

所以唯一的办法向服务器端方法在另一个地方交流/项目是调用Web服务,可以的执行异步HTTP(阿贾克斯)申请喜欢这个

So the only way to communicate to a server side method in another place/project is by calling a web service, you can perform an asynchronous HTTP (Ajax) request like this

$.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    url: "http://yourSite/yourApp/YourWebService.asmx/methodName",
    data: JSON.stringify({firstField: 123}),
    success: function (msg) {
        alert('It Works!');
    },
    error: function (xhr, status, error) {
        alert('It does not work!');
    }
});

也许你可以找到跨域调用的问题,这意味着你不能在客户端上从一个域不是Web服务的域调用Web服务。

Probably you could find issues with cross-domain calls, it means that you can't call web services on the client from a domain that is not the web service's domain.

我建议使用一个纯JavaScript CORS替代,xDomain;我用它在为谁工作跨域的问题,也有一个很好的例子,并解释得非常好如何使用它

I recommend to use a pure JavaScript CORS alternative, xDomain; I have used and it really works for the cross-domain issues, also it has a nice examples and explains very well how to use it

这篇关于的Visual Studio 2015年科尔多瓦Apache服务器端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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