码信号和节点js与现在的js集成 - 如何访问视图文件 [英] codeigniter & node js integration with now js - how to access view files
问题描述
我想集成codeigniter和node.js,但我有困惑,如何执行
node.js和codeigniter。
i want to integrate codeigniter and node.js but i am having confusion that how to execute both node.js and codeigniter.
我已成功安装并运行nowjs示例: http://nowjs.com/doc/example
I have successfully installed and ran the nowjs sample: http://nowjs.com/doc/example
如何访问codeigniter(或任何php框架)的视图文件到node.js。
how to access view files of codeigniter(or any php framework) into node.js.
我有困惑,因为codeigniter执行url http:// localhost / xyz
code> http:// localhost:8080 / xyz
i have confusion because codeigniter executed with url http://localhost/xyz
while node.js executed with http://localhost:8080/xyz
所以我必须在浏览器中写我可以使用node.js& codeigniter?
so which url i have to write in browser from which i can use both node.js & codeigniter?
推荐答案
这里是如何使代码指示器和nodej彼此交谈。
Here is how ii made codeigniter and nodejs talk to each other.
我有我的codeigniter应用程式在 http://mydomain.com/controller/function/ 上执行,我有我的nodejs (nowjs)在 http://mydomain.com:8080 上运行,
i have my codeigniter app running on http://mydomain.com/controller/function/ and i have my nodejs(nowjs) running on http://mydomain.com:8080 ,
用户将使用codeigniter URL,当打开页面,我有我的CI视图页面上连接到我的Nodejs应用程序,类似这样的脚本:
users will use codeigniter URL and when open the page, i have this script on my CI view page that connects to my Nodejs app, something similar to this :
<script src="http://mydomain.com:8080/nowjs/now.js"></script>
<script>
$(document).ready(function(){
now.receiveMessage = function(name, message){
$("#messages").append("<br>" + name + ": " + message);
}
// Send message to people in the same group
$("#send-button").click(function(){
now.distributeMessage($("#text-input").val());
$("#text-input").val("");
});
now.name = prompt("What's your name?", "");
// on establishing 'now' connection, set server room and allow message sending
now.ready(function(){
// Pick up list of available chatrooms from server and populate dropdown
setServerRoomFromList(now.serverRoomsList);
// By default pick the first chatroom
now.changeRoom($('#server-room').val());
// Connection established and room set; allow user to start sending messages
$("#send-button").removeAttr('disabled');
});
// On change of drop down, clear text and change server room
$('#server-room').change(function(){
$("#messages").html('');
now.changeRoom($('#server-room').val());
});
});
// populate the #server-room dropdown
function setServerRoomFromList(roomList){
$('#server-room').empty();
$.each(roomList, function(key, value)
{
$('#server-room').
append($("<option></option>").
attr("value",key).
text(value));
});
}
</script>
ant他们可以很好地交谈!
ant they can talk to each other very well !!
这篇关于码信号和节点js与现在的js集成 - 如何访问视图文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!