只需从表单标签中删除该操作即可
$_SERVER['PHP_SELF'];
你可以这样做
<form action="" enctype="multipart/form-data" method="post" class="class" id="id" autocomplete="off">
<input type="text">
<input type="submit" value="SUBMIT">
</form>
或者你可以这样做
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" method="post" class="class" id="id" autocomplete="off">
<input type="text">
<input type="submit" value="SUBMIT">
</form>
AJAX
$(document).ready(function() {
$('#form_id').submit(function() {
$.ajax({
url: 'your_page.php // and if it this page just put it's name.php',
data: {field1: value1, field2: value2},
type: 'post',
dataType: 'json',
beforeSend: function() {
// do something like show the loading,,,
},
success: function() {
// do something after the request has status of 200,,,
},
error: function() {
// do something if the request has error like 400, 500 server internal error/ page not found etc,,,
},
complete: function() {
// do something finish,,,
},
});
return false;
});
});