我對ajax和JavaScript仍然很陌生,所以我很抱歉缺少一些可能非常基本和前沿的東西。提交ajax onblur
我正在嘗試提交表單onblur。我正確地調用了該函數,但我不確定如何引用表單中的變量。當我從表單中移出時,我在Firebug中看到它調用了addNotes.php文件,但沒有變量被傳遞。
這裏的JavaScript的:
// Ajax to submit an edited post to the database.
function sendNotes() {
// we want to store the values from the form input box, then send via ajax below
var $form = $(this);
$.ajax({
type: "POST",
url: "includes/addNotes.php",
data: $form.serialize(),
success: function(){
}
}); // End .ajax function
return false;
} //End submit function()
現在,這裏的HTML:
<form id="adminNotes" method="post" name="adminNotes" action="">
<textarea name="notes" id="notes" onblur="sendNotes()"></textarea>
</form>