Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138163

Use MySQL query to autocomplete search

$
0
0

I'm trying to autocomplete from a list of user that I have in my database, I get the query but then how do I pass it to my client side JavaScript to execute it and complete the jQuery autocomplete? I'm using ejs as a rendering engine and using MVC. I'm just confusing how and why I cannot use jQuery normally in my controller

My ejs / HTML:

<div class="input-field col s6">
  <input id="first_name" type="text" class="validate typeSearch" />
  <label for="first_name">Name</label>
</div>

And my code in the controller for the page ( the search is just a tiny bit that comes in a modal)

app.get("/superDash/:userID/:projectID", (req, res, next) => {
  connection.query("SELECT user.uName, user.surname from `user`;",
    (err, row, field) => {
      if (!err) {


        res.render("superDash", {
          autocom: row
        });
      } else {
        console.log(err);
      }
    }
  );
});

Viewing all articles
Browse latest Browse all 138163

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>