-1

I have my HTML page with a lot of forms inside. I would like just to send a post request with a form and I would like to change the aspect only of a button without rerendering the whole page after the invocation of a router.post function server-side. How can I do that?
Here is my code:

          {{#if alreadyapplied}}
            <input type="hidden" name="idJob" value="{{id}}">
            <br><br>
          </div>
          <button type="input" class="btn btn-danger">Already applied</button>
          {{else}}
          <form method="POST" action="/users/applynow">
            <input type="hidden" name="idJob" value="{{id}}">

            <input type="hidden" name="email" value="{{x.utente.email}}">
            <br><br>
        </div>
        <button type="input" class="btn btn-primary">Apply Now</button>
        </form>
        {{/if}}

On the server side, I've got a router.post("/applynow") function that handles the post request. It should handle more or less just like a "like" to a post of facebook.

Andrea Fresa
  • 351
  • 2
  • 18

1 Answers1

0

If you want to send data and receive back a response and have some of your view changed without refreshing the page, you can do that via an AJAX call. For example. you have a view component which holds a balance of money. And after clicking a button you don't refresh the page but notice that the balance changes.

Edwardcho Vaklinov
  • 118
  • 1
  • 1
  • 11