问题描述
我正在开发一个基于 jQuery 的数据透视表.
I'm developing a jQuery-based pivot table.
目标不是网络应用,而是基于桌面的应用 (C++).在我的想法中,应用程序从数据库中检索数据,然后传递到 html 页面,然后通过数据透视表插件显示.
The goal is not a web app but a desktop-based application (C++). In my idea, data is retrieved by the application from the database, then passed to a html page and then showed through the pivot-table plugin.
没有网络服务器,包含插件的网页无法访问数据库.
There is no web server and the web page containing the plugin cannot access to the database.
那么,如何高效的传递数据呢?我在这里看到了关于这个问题的其他问题,但我认为我们处于不同的情况.当然我可以把数据写到txt/xml/js文件中,但是我经历过,对于大量的数据,写文件的成本很高.
So, how to pass data in an efficient way? I've seen other questions here on SO around this matter, but I think we're in a different scenario. Of course I can write the data in a txt/xml/js file, but I've experienced that for huge amounts of data, writing down files is costing a lot.
推荐答案
如果您不想为您的应用程序添加对 http 协议的支持,并且您不想写入其他文件,那么 IMO 是您的最佳选择打赌是为您的应用程序创建一个包装 http 服务器.然后 javascript 页面可以访问正在运行的包装器,它可以与您的真实"应用程序对话.
If you don't want to add support for the http protocol to your application, and you don't want to write to additional files, then IMO your best bet is to create a wrapping http server for your application. Then the javascript page can access the running wrapper which can talk to your "real" application.
您可以使用twisted 框架、ruby 使用rails 和捆绑的webrick 服务器或v8 Javascript 引擎node.js 在python 中相对轻松地创建这样的服务器.(我相信还有很多其他选择)
You could create such a server relatively easily in python using the twisted framework, ruby using rails and the bundled webrick server, or the v8 Javascript engine node.js. (I'm sure there's dozens of other options out there too)
哪种最适合您在很大程度上取决于您使用过哪些语言以及您的部署要求是什么(支持的操作系统、现有安装的应用程序、安装大小、软件的许可条款等)
Which of there would be best for you will depend a lot on which languages you have experience with and what your deployment requirements are (supported OSes, existing installed applications, installation size, license terms on your software etc.)
这篇关于如何将数据从 C++ 应用程序传递到 Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!