Update the database by clicking object without refresh

Asked

Viewed 60 times

-4

It is the following guys I have a table of data as you can see below, in it has the icon of an eye, of which when clicked makes a direction to another page passing the "id" of the file via url and giving an update in the line of the file, modifying a field from zero to one, soon after done this goes back to the table page and changes blue eye to red and vice versa, so far so good, my problem is the following I wanted to do exactly this process only that without running the refresh on the page so that when clicked it would update and change the color of the icon without the need to refresh the page, someone would know how to do this ? inserir a descrição da imagem aqui

  • To not refresh you have to use Ajax

1 answer

0


In general, you would need to create a endpoint/route on your system, which allows you to do the update you want by passing the id and the field value, and returning if the operation was a success. With this done, you, using Javascript, would have to make a request for the endpoint that you created (by clicking the button, of course), passing the desired parameters and updating the HTML elements of the page as the result obtained by the request.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.