2012-12-18 49 views
1

你必須忍受我,因爲我剛開始使用jQuery,所以這可能是一個非常簡單的事情,我可以忽略。 我有一個正在開發的網站的登錄表單,並且我正嘗試使用ajaxSubmit來發送請求丟失密碼的請求。此請求源於模態div上的表單。無法使用ajaxSubmit:TypeError:Object [object Object]沒有方法'ajaxSubmit'

形式:

<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"); 
         } 

        } 
       }); 

      }); 

     }); 

然而,當我真正按下按鈕,我得到以下控制檯錯誤: 遺漏的類型錯誤:對象的翻譯:沒有方法'ajaxSubmit'

我檢查了ID的全部匹配,並且正在加載相關的js文件。

我現在已經沒有想法了,任何人都可以幫忙嗎?

+0

你使用插件來使用ajaxSubmit嗎? –

+1

你在使用插件嗎?因爲ajaxSubmit是JQuery表單插件的一部分,如果是這種情況,請檢查它是否正確包含插件 –

+0

是的,我有這個在頭: Terrawheat

回答

1

只是爲了將來的參考,錯誤被拋出,因爲我是一個白癡:/ 我顯然包括兩個不同版本的jQuery,只要我刪除了額外的包括它開始工作。

1

有相同的錯誤信息,並通過添加jQuery表單插件,它具有ajaxSubmit函數解決。

相關問題