Button Issue with ajax function

Button Issue with ajax function
0.0 0

#1

when I click the search button in the form element it does not output the Ajax success function , however the button outside the form does output the Ajax success function!


#2

an HTML id attribute must be unique for any element, you have have 2 elements with the same id , change one of them


#3

You need to supply an argument representing the event object and then use event.preventDefault() to stop the default action of the form (which is currently set to “” which will just reload the page).
HTML

 <button id="srch-btn" onclick="loadData(event);">Search</button>

JavaScript

function loadData(event) {
   event.preventDefault();

#4

Yay it works! tysm !