How to call a node.js script in a javascript tags …
up vote
-1
down vote
favorite
I am making an api call and want to store the result into a table. Since the response i get is stored in javascript i have to use node.js for database connection (please let me know if there is a better way around). For that i have a node.js script. I want to call the node.js script in the javascript tags where i make the api call so that i can save the response in the table.
So how do I call a node.js script in a javascript?
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "",
password: "",
database: ""
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
//Insert a record in the "customers" table:
var sql = "UPDATE portal SET similarity=$semantic WHERE id=$id[i]";
con.query(sql, function (err, result) {
if (err) throw err;
console.log("1 record inserted");
});
});
javascript node.js
add a comment |
up vote
-1
down vote
favorite
I am making an api call and want to store the result into a table. Since the response i get is stored in javascript i have to use node.js for database connection (please let me know if there is a better way around). For that i have a node.js script. I want to call the node.js script in the javascript tags where i make the api call so that i can save the response in the table.
So how do I call a node.js script in a javascript?
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "",
password: "",
database: ""
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
//Insert a record in the "customers" table:
var sql = "UPDATE portal SET similarity=$semantic WHERE id=$id[i]";
con.query(sql, function (err, result) {
if (err) throw err;
console.log("1 record inserted");
});
});
javascript node.js
1
You cannot directly call a Node.js script from an HTML document using a<script>
tag... is that what you're trying to do? If so, you would need to use something like Express to create a back end API with an API route that would do the thing you have above.
– jakerella
Nov 19 at 18:24
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am making an api call and want to store the result into a table. Since the response i get is stored in javascript i have to use node.js for database connection (please let me know if there is a better way around). For that i have a node.js script. I want to call the node.js script in the javascript tags where i make the api call so that i can save the response in the table.
So how do I call a node.js script in a javascript?
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "",
password: "",
database: ""
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
//Insert a record in the "customers" table:
var sql = "UPDATE portal SET similarity=$semantic WHERE id=$id[i]";
con.query(sql, function (err, result) {
if (err) throw err;
console.log("1 record inserted");
});
});
javascript node.js
I am making an api call and want to store the result into a table. Since the response i get is stored in javascript i have to use node.js for database connection (please let me know if there is a better way around). For that i have a node.js script. I want to call the node.js script in the javascript tags where i make the api call so that i can save the response in the table.
So how do I call a node.js script in a javascript?
var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "",
password: "",
database: ""
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
//Insert a record in the "customers" table:
var sql = "UPDATE portal SET similarity=$semantic WHERE id=$id[i]";
con.query(sql, function (err, result) {
if (err) throw err;
console.log("1 record inserted");
});
});
javascript node.js
javascript node.js
edited Nov 19 at 18:23
jakerella
9,48022546
9,48022546
asked Nov 19 at 17:25
Esha Patel
21
21
1
You cannot directly call a Node.js script from an HTML document using a<script>
tag... is that what you're trying to do? If so, you would need to use something like Express to create a back end API with an API route that would do the thing you have above.
– jakerella
Nov 19 at 18:24
add a comment |
1
You cannot directly call a Node.js script from an HTML document using a<script>
tag... is that what you're trying to do? If so, you would need to use something like Express to create a back end API with an API route that would do the thing you have above.
– jakerella
Nov 19 at 18:24
1
1
You cannot directly call a Node.js script from an HTML document using a
<script>
tag... is that what you're trying to do? If so, you would need to use something like Express to create a back end API with an API route that would do the thing you have above.– jakerella
Nov 19 at 18:24
You cannot directly call a Node.js script from an HTML document using a
<script>
tag... is that what you're trying to do? If so, you would need to use something like Express to create a back end API with an API route that would do the thing you have above.– jakerella
Nov 19 at 18:24
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53379778%2fhow-to-call-a-node-js-script-in-a-javascript-tags-script-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You cannot directly call a Node.js script from an HTML document using a
<script>
tag... is that what you're trying to do? If so, you would need to use something like Express to create a back end API with an API route that would do the thing you have above.– jakerella
Nov 19 at 18:24