提交我有一個HTML表單jQuery的驗證,與submitHandler
<form method="POST" action="" name="myform" id="myform">
<input type="text" name="email" id="email" />
<input type="supmit" name="submit" id="submit" value="submit" />
</form>
和jQuery的代碼:
$(document).ready(function(){
var validator = $("#myform").validate({
ignore: ".ignore",
rules: {...},
messages: {...},
submitHandler: function(form) {
$.post('usr.php?resetpw', $(this).serialize(), function (data, textStatus) {
form.submit();
alert(data.inf);
},'json');
},
});
也PHP代碼usr.php不會獲得$ _ POST - 變量(isset($_POST['email'])
= false
)
if(isset($_GET['resetpw'])) {
$loggingData = array(
'inf' => utf8_encode("Your email address is: ".$_POST['email']),
'errorEmail' => '',
'mailExists' => '',
'success' => '',
);
}
echo json_encode($loggingData);
什麼是後達到PHP變量正確的代碼?
謝謝
什麼樣的記錄都做了什麼?你有沒有在Firebug/Developer工具中檢查請求以查看數據是否真正發送?嘗試'$('#myform')。serialize()','this'可能不是指那個函數內部的形式。 –
或使用'$(form).serialize()' –