2

I'm using Node.js as server with Mysql as database for storing logged in usernames. Can I use AJAX to make a sql database query and return the list of usernames?

To be specific I want to use XMLHttp request and get the results without reloading the page.

Please excuse me if the question doesn't make sense. I'm from Mechanical Engineering background.

5
  • Sure, ajax is independent of what backend technology you want to use. However you mention you have a node.js server, why do you need .asp files ? Commented Jun 1, 2017 at 6:10
  • I've fast search this site. Might to be helpful for you: stackoverflow.com/questions/42971941/… Commented Jun 1, 2017 at 6:11
  • 1
    go through this - gistpages.com/posts/… Commented Jun 1, 2017 at 6:14
  • @SujalMandal Thank you so much. I have actually finished that part, It reloads the page and then gives the results. To be more specific I wanted to use XMLHttp() request and stay on same page. Commented Jun 1, 2017 at 6:46
  • @VasylMoskalov Thank you so much. Commented Jun 1, 2017 at 6:50

1 Answer 1

3

Setup js file to server express, express will handle routes route for CRUD

express will also open connection with DB using ORM like Sequelize and whenever a CRUD operation occurs from the front end -> Node back end then your express app will run the code in the appropriate route the route will have the logic for CRUD on the DB queries.

this is a long process to explain requires knowledge of how to request the backend for information via url -> backend listerers of a sort lol

that's the gist.

front end will send ajax -> to backend and backend will listen to that route or something like that.

@Sujal Mandal he found a good reference go with his answer, i just skimmed it but looks right.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.