我一直在嘗試幾個小時才能完成這項工作,但在進行ajax調用時我沒有收到任何迴應。我對Ajax是新手,它可能是您將會看到但我無法做到的事情。我很感激你的幫助。這是我的代碼。試圖讓簡單的登錄表單上的AJAX工作
HTML
<script>
$("#submitlogin").click(function() {
inputs = {
"logInUsername" : $('input[name=logInUsername]').val(),
"logInPassword" : $('input[name=logInPassword]').val()
};
// since this is a username and password combo you will probably want to use $.post
$.ajax ({
type: "POST",
url: "loggnow.php",
data: inputs,
success: function() {
$("#login").html("You are now logged in!");
}
});
});
</script>
loggnow.php
<?php
extract($_POST);
if($_POST)
{
echo 'Yes the ajax posted';
}
?>
當您嘗試手動訪問該頁面時,您會看到Javascript錯誤或PHP錯誤嗎? 也確保你給PHP文件的正確路徑,你有什麼暗示,這兩個文件都在同一目錄 –
是的,我能夠通過網址訪問頁面,是的,他們在同一個目錄 – user710502