Sorry but, I am getting crazy with this problem. Each time I call jQuery it reloads my page.
HTML file:
<body>
<form enctype='multipart/form-data' id="form_id">
---- some inputs here ------
<input type='submit' value='Basic search'>
</form>
<script type="text/javascript">
$(document).ready(function() {
$(document).on('submit', '#form_id', function() {
var data = $(this).serialize();
$.ajax({
type : 'POST',
url : 'phpfile.php',
data : data,
success : function(data)
{$(".result").html(data);} //result is div that i want display result in it
});
return false;
});
});
</script>
</body>
Edit 1:
I use <input type ='button'>
insted of <input type = 'submit'>
but it does not works.
And I add
$(document).on('click', '#search_button', function(e)
{
e.preventDefault();
But, it does not works!
Edit 2: The error msg in console: Form contains enctype=multipart/form-data, but does not contain method=post. Submitting normally with method=GET and no enctype instead.
A form was submitted in the windows-1252 encoding which cannot encode all Unicode characters, so user input may get corrupted. To avoid this problem, the page should be changed so that the form is submitted in the UTF-8 encoding either by changing the encoding of the page itself to UTF-8 or by specifying accept-charset=utf-8 on the form element.
Form contains a file input, but is missing method=POST and enctype=multipart/form-data on the form. The file will not be sent.
mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create
The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help http://xhr.spec.whatwg.org/
The Web Console logging API (console.log, console.info, console.warn, console.error) has been disabled by a script on this page.