私はjQueryを使い始めたばかりなので、これは私が見落としている非常に単純なことかもしれません。私が開発しているサイトのログイン フォームがあり、ajaxSubmit を使用して、失われたパスワード リクエストのリクエストを送信しようとしています。このリクエストは、モーダル div のフォームから発生します。
形:
<div id="dialog" style="display: none" title="Retrieve your password">
<p>
Please enter your username below and you will have a new password sent to the email address you registered with the account.
</p>
<form id="passform" action="comment.php" method="post">
<input type="text" name="user" id="user">
</form>
</div>
リクエストを送信するjQuery:
$(document).ready(function()
{
function doit(formData, jqForm, options)
{
// formData is an array; here we use $.param to convert it to a string to display it
// but the form plugin does this for you automatically when it submits the data
var queryString = $.param(formData);
// jqForm is a jQuery object encapsulating the form element. To access the
// DOM element for the form do this:
// var formElement = jqForm[0];
alert('About to submit: \n\n' + queryString);
// here we could return false to prevent the form from being submitted;
// returning anything other than false will allow the form submit to continue
return true;
}
$("#getpass").click(function()
{
$("#dialog").dialog(
{
autoOpen : true,
resizable : false,
height : 270,
modal : true,
hide : "fold",
show : "fold",
buttons :
{
"Retrieve Password" : function()
{
$("#passform").ajaxSubmit(
{
url : "php/lostpassword.php",
type : "post",
success : doit
});
return false;
},
Cancel : function()
{
$(this).dialog("close");
}
}
});
});
});
しかし、実際にボタンを押すと、次のコンソール エラーが発生します: Uncaught TypeError: Object [object Object] has no method 'ajaxSubmit'
ID がすべて一致し、関連する js ファイルが読み込まれていることを確認しました。
今、アイデアが不足しています。誰か助けてもらえますか?