Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

303
Views
Refresh only portion of page (td) after perform database update query (Mysql), using Express (node js)

i'm new to node js and express. I need to refresh only a portion of page (a td in table or the whole table) after perfoming a database update query using express. So in this way i'll show the updated value for the td without refreshing the whole page. The update query is performed by click an <a> element. Thank you.

Here some code i use:

Html from index.ejs page:

<thead>
<tr><th>Goals</th></tr>
</thead>
<tbody>
        <%
        if(userData.length!=0){
        var i=1;
        userData.forEach(function(data){
        %>
<tr>
<td><a href="add-goal?id=<%= data.id %>"><i class="bi bi-plus-circle-fill text-success"></i></a><span class="badge bg-primary rounded-pill"><%=data.goals%></span></td>
</tr>
        <%  i++; }) %>
        <% } else{ %>
          <tr>
            <td colspan="10">No Data Found</td>
        </tr>
        <% } %>
<tbody>

Select Query to database:

router.get('/players-list', (req, res, next) => {
    db.query('SELECT * FROM players_list ORDER BY goals DESC;', (err, data, fields) => {
    if (err) throw err;
});
});

Update Query to database:

router.get('/add-goal', (req, res, next) => {
  db.query('UPDATE players-list SET goals = goals + 1 WHERE id = ?', req.query.id, (err, data) => {
    res.redirect('players-list');
  });
});

P.S. It doesn't make much difference if i refresh the td, the tr or the whole table.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!