1

In the below form when we click on save we are getting only form submit request to server.

    <form id="form1" action="service1" method="POST">
     <button id="id1" onclick="getcount('emp')" >clickhere</button>

     <input id="save"  type="submit" class="btn-small btn-primary" value="Save" name="Save"/>

     </form>

But when we click on clickhere button, we are getting two requests to server. i.e. 1. post call service1 2. service call in getCount() function.

But I need only getCount() function service call.

How can we handle the above scenario?

Karthik P
  • 53
  • 1
  • 8

1 Answers1

3

Add type="button" to the button that makes the getcount() call so that it overrides the default "submit" behaviour.

<button id="id1" type="button" onclick="getcount('emp')" >clickhere</button>

Newah
  • 102
  • 1
  • 9