Button Issue with ajax function

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!

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

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();
1 Like

Yay it works! tysm !