简体   繁体   English

从node.js将数据获取到HTML页面

[英]Getting data from node.js into HTML page

I am new to node.js. 我是node.js的新手。 Say node.js is running on 说node.js正在运行

localhost:9090//nodejs/server/messages/1 本地主机:9090 // nodejs / server / messages / 1

In that url.Application is running in 在那个url.Application正在运行

localhost:8080/ 本地主机:8080 /

I want to access the node,js result in a HTML page. 我想访问HTML页面中的node,js结果。

function get_message() {
  $.getJSON('/nodejs/server/messages/1', function (result) {
    var df = result;
    document.getElementById('txtCompanyId').value = result[0]['CompanyID'];
    document.getElementById('txtCompanyName').value = result[2]['CompanyName'];
  });
}

This function I am using leads to a cross-domain exception. 我正在使用的此功能导致跨域异常。 I solved it using proxy settings in Apache. 我使用Apache中的代理设置解决了该问题。 How to configure this setting in IIS? 如何在IIS中配置此设置? Or how to call that node.js url in Javascript while running on IIS server? 还是在IIS服务器上运行时如何用Javascript调用该node.js URL?

Then how to host the node.js in IIS? 然后如何在IIS中托管node.js?

Please help. 请帮忙。

I think you can use NowJS lib from https://github.com/Flotype/now , http://nowjs.com , or http://socket.io . 我想你可以使用NowJS LIB从https://github.com/Flotype/nowhttp://nowjs.com ,或http://socket.io Another thing you could try is messaging concept. 您可以尝试的另一件事是消息传递概念。

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

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