Hello guys i don't know to submit a form without page refresh. This is my code:
My form:
<form method="POST" id="post123" action="" enctype="multipart/form-data"> <input class="form-control input-lg" name="book_name" id="inputLarge" type="text"> <input class="form-control" name="book_price" type="number"> <textarea class="form-control" id="exampleTextarea2" name="book_description" maxlength="100" rows="7"></textarea> <textarea class="form-control" name="book_content" id="exampleTextarea4" maxlength="200" rows="7"></textarea> <input type="file" name="file" id="imgInp44" > <button type="submit" name='action' id="sendbutton21" value="post1" class="btn btn-primary"> Submit </button> </form> Javascript:
$("#sendbutton21").click(function() { var url = "http://localhost:5000/magazin_insert"; // the script where you handle the form input. $.ajax({ type: "POST", url: url, data: $("#post123").serialize(), // serializes the form's elements. success: function(data) { alert(data); // show response from the php script. } }); return false; // avoid to execute the actual submit of the form. }); How i can modify my code to submit along with text a file towards the mysql db?