backboneJS application runs fine in NodeJs but not in any other server? - node.js

I was trying to load a json file in Collection of BackboneJS. While trying to run this through nodeJS server, it works fine. But once put in a server environment like XAMPP or even in a remote server it does not work? Any link would be a nice help. ( For reference my code is at github : https://github.com/saumya/backboneJS-basics )
thanks

Hey thanks for the helping hand.
Probably I did not understand the situation, so the question is not correct as I see now.
The modified question is:
I have a frontend Application running on NodeJS server at some port.
I am trying to load JSON from another server running on another server.
The answer of #Floby is the way I solved it. Its the CORS thing on the server which provides the JSON. It took me sometime to understand what is happening.

Related

I have a problem with my NODEJS API on planetHoster

I created my very first NODEJS API. Locally, it works well but I just hosted it on planetHoster and it doesn’t work anymore. When I enter my query, I find the error "Cannot GET/Nodev2/idcc/list" then my route was functional locally. Do you have any assumptions? Thank you in advance!
I can share my code if you want see
I tried to change directory/file names

FormData submit NodeJS returns 503 unavailable

I'm trying to deploy my application to Heroku (as usual) and I keep getting 503 Service Unavailable when trying to upload anything through my router handler (Multer)!
it's not related to any packages since I tried different projects with and without multer and the same return
Hi #Mahmoud Nasr,
Kindly run the nodejs code locally in system and check for any issues.
If it works then the issue is with Heroku server configurations or the
server is not available.
If it not working in local in the first place kindly update the snippet,
let's figure it out.
Regards,
Muhamed

Update a web page using socket.io when database is updated by another page

I'm starting playing with NodeJS and Socket.IO and I've got a question regarding communication between pages of my application.
I've got a Node JS script (get_new_data) which is periodicaly executed using a cron task. This script will get information through Internet, parse them and write them in a PG Database. This is ok.
I've got a secondary script (show_last_data) using Node/Express/Socket.io that displays the last information of the DB when it is executed. This is also ok, right now.
What I would like now, is that the script show_last_data would be notified when new data are inserted in the database and the corresponding display divs to be updated.
Can get_new_data connect to show_last_data even if it is not the server that produces the page ? Or should I manage this in another way ?
Thanks for help
I've finally found a way to manage this using socket.io-client.
This page was particulary helpful to solve my question : socket.io as a client

How to connect angular2 server side with php

I recently bought a new template for my site written in angular2, i did a short course on it and started to work and everything fine.
Now come the the part where i try to connect it to my DataBase and i cant figure it out...
after a little bit of reading i saw that i need to use nodejs in order to speak with the server side, is that true?
can i use php or i must use the nodejs api to work with my Db?
am i missing the concept of the angular2 or something? can someone post a basic script of angular working with php example , i just cant find it.. :(
thanks a lot :)
The most common scenario is that you use the Http service in Angular that makes XHR (Ajax) requests to the server to fetch data (not HTML).
You can use any server that is able to receive, process and response to XHR requests. Therefore PHP is as suiteable as node.js (or .NET, Java, or any other web server)
See also https://angular.io/docs/ts/latest/guide/server-communication.html

How to access NodeJS data through cakePHP?

Dummy question here but I haven't found any answer on the web for now.
I'm working on a cakephp website, installed on a Raspberry Pi, which is supposed to be able to connect wireless-ly through a local network to an Arduino YUN, get its components list.
For example :
"A LED is connected on ports :
Input : 2,
Output : 6;
and is currently on"
And change the input value :
"turn the LED off"
I'm not supposed to reload the webpage to see the change occurring.
So I figured out I needed NodeJS to send/receive the informations with websockets but I don't know how to connect NodeJS -running on its own webserver- to cakephp.
I'm a complete rookie with NodeJS, just did a few tutorials earlier, so I'm stuck here.
Does anyone know how to deal with this ?
Thanks in advance,
There are a few different libraries you can use to connect to the node server.
http://elephant.io/
https://github.com/bergie/dnode-php
You can, of course, just fall back to sending http requests (curl) from your cakephp app to the node server.
I have a few discoveries to add that may help some people.
While searching more deeply on DNode and elephant.io I found a cakePHP plugin called cake_websocket which make use of socket.io.
Seems to me that it is an equivalent to elephant.io specialized in cakePHP (while elephant.io is 'just' PHP).
I hope it can help someone !
Instead of using any library.
You can try iframe tag with src to your 'node.js' view.html.
So, listen for events on view.html which are triggered from your 'cakephp' view.html
So, you will have cakephp->view.html talking to node.js->view.html which is connected to node.js->index.js(server)

Resources