I am coding a simple app with html and node.js It is my first app by node.js, javascript and html
By node I want send a json, when a url is called (In my local machine the below ip is called : 127.0.0.1/local)
when I call that address, the expected info returned to browser correctly. Also I added a button in my html page and need to call above address, to get JSON data.
I have tried the solution of accepted answer at here
but I got this error:
XMLHttpRequest cannot load http://127.0.0.1/local Origin server is not allowed by Access-Control-Allow-Origin node.js
What is problem? I think the provided information is completed, but if it is not, let me know to share my code.
- Update
Ok, I see I need to explain my exact target and provide my code;
I am developing a program by Node.js I have a mysql database which I want to get some info from db and show on html page. I use bookshelf, express, lodash, router on my database js file so I get data from db by calling
127.0.0.1:3002/local
I have a button on my html page; and need to get info when user touch it. My html page is running on
127.0.0.1:8080
So I think there is no need to provide Access, both of db and html is running on one server.
Maybe my solution to call db data by XMLHttpRequest is not a right solution. I am asking is it only way to call data or not?