javascript - Push notification to web browser using nodejs -


Whenever there are any database changes, I am working on real-time information projects. I am able to achieve a half success by now, but unable to resolve some issues. Currently, my code reads a static client.html file and displays the database changes in the file. What is okay, however, what I want to achieve is that instead of reading a static file, my server.js file should be in my project URL such as http: // localhost / dashboard / < / Code> instead of http: // localhost: 8000. My code is:

Server.js

   

Client.html

  ; Body & gt; & lt; time & gt; & lt; / Time & gt; & Lt; Div id = "container" & gt; Loading ... & lt; / Div & gt; & Lt; Script src = "socket.io/socket.io.js" & gt; & Lt; / Script & gt; & Lt; Script src = "http://code.jquery.com/jquery-latest.min.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; // Create a new web site var socket = io.connect ('http: // localhost: 8000'); // On the received message, we print all the data inside the # container div socket. ('Notification', function (data) {var usersList = "& lt; dl>"; $ .eee (data.ours, function (index, user) {usersList + = "& lt; dt & gt;" + User.user_name + "& lt; / dt> \ n" + "& lt; dd & gt;" + user.user_desc + "\ n" + "& lt; figure & gt; & lt; img class = 'Img-polaroid' width = '50px' src = '"+ user.user_img +"' / "gt; & lt; / figure & gt;" "& lt; / dd>";}); usersList + = "& Lt; / dl & gt;"; $ ('# container') .HTML (usersList); $ ('time') .html ('last updated:' + data.time);}); & Lt; / Script & gt; & Lt; / Body & gt;  

If I am able to redirect it to my project link, then I can copy the code (code copy of the code) on every page of my project. Change. I was trying this for a few days but in reality it stumbled how I should get it.

Any help would be highly appreciated.

Thanks


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -