我正在使用ajax将表单提交到php页面以便进行查询。 问题是$ _POST是空的。 我在这里做错了什么? 任何想法?变量不从ajax发送到php
FORM
<div id="button_left">
<form>
<label>
<input type="text" class="search" size="30" style="margin-left:20px;" name="epitheto" id="epitheto" placeholder="Επίθετο" />
</label>
<label>
<input type="submit" value="Αναζήτηση" />
</label>
</form>
</div
功能
$(function() {
$('#button_left').on('submit', function (e) {
e.preventDefault();
$.ajax({
type: 'post',
url: 'people_name_query_final.php',
data: $('form').serialize(),
success: function() {
$("#pelates_last_name_query").slideDown("slow");
$("#pelates_last_name_query").load("people_name_query_final.php");
}
});
});
});
PHP
if(isset($_POST['epitheto'])){
//some code
}
对不起你的问题,是这是你的问题,你是即使你的'POST'是空的,也可以提交表单。让我知道,means isset函数没有做你期望的。谢谢 – 2014-10-05 08:42:35
问题是表单正在提交,成功函数正在工作,但$ _POST是空的,所以在PHP中的所有代码没有运行。 – 2014-10-05 08:45:13
看到我给出的答案。它可能会帮助 – 2014-10-05 08:52:21