在以下代碼dataString不在comment.php頁面訪問傳遞。我用$_POST['name']
來獲取變量名稱。變量不是通過PHP頁面使用AJAX
$(document).ready(function(){
$("#submit").click(function() {
var dataString='name=vinay';
$.ajax({
type: "POST",
url: "comment.php",
data: dataString,
cache: false,
success: function(html){
//.after(html);
alert(html);
}
});
clearInput();
});
$("#commentForm").submit(function() {
return false;
});
function clearInput() {
$("#commentForm :input").each(function() {
$(this).val('');
$("#submit").val('Post');
});
}
});
這段代碼有什麼問題嗎?任何幫助,將不勝感激。提前致謝。
嘗試給'name:vinay' – gulshanm01
print_r($ _ POST)在comment.php上給你什麼? – bart2puck
其返回數組() – Vinie