lundi 29 décembre 2014

How to prevent from page refresh on submit button click


i have form with one input and one submit button.



<form method='POST' action='' enctype='multipart/form-data' id="form_search">
<input type='hidden' name="action" id="form_1" value='1' />
</span><input id="query" type="text" name="mol" value="">
<input type='submit' value='Search' name="Search" id="Search" />


on form submission form input data goes to php below code



if (isset($_POST['Search'])) {
$_SESSION["query"] = $_POST["mol"];
$_SESSION["action"] = $_POST["action"];
}


i want to avoid page refresh on form submission. i tried e.preventDefault() and return false; methods in my java script but not working(this methods helping me from page refresh but does not allowing me to send data to php code)


please help me out of this problem, please suggest working ajax code for this problem.





Aucun commentaire:

Enregistrer un commentaire