2013-04-17 105 views
1

當我嘗試向我的表單添加ajaxSubmit時,出現錯誤「Uncaught TypeError:Object [object Object] has no method'submit'」。Uncaught TypeError:Object [object Object] has no method'submit'

jQuery代碼:

$(document).ready(function() { 
    var options = { 
     beforeSubmit: showRequest, 
     success:  showResponse 
    }; 

    $('#bform').submit(function() { 
     $(this).ajaxSubmit(options); 
     return false; 
    }); 
}); 

function showRequest(formData, jqForm, options) { 
    var queryString = $.param(formData); 
    alert('About to submit: \n\n' + queryString); 
    return true; 
} 

function showResponse(responseText, statusText, xhr, $form) { 
    alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + 
      '\n\nThe output div should have already been updated with the responseText.'); 
} 

形式HTML:

<form id="bform" action="/rest/submit_byte" method="post"> 
    <label for="submitted_byte">Submit a Byte:</label> 
    <textarea id="submitted_byte" name="submitted_byte" style="margin: 2px; width: 385px; height: 201px;"></textarea> 
    <input type="submit" id="submit_button" value="Submit" /> 
</form> 
+1

恐怕問題不在你顯示的代碼上。我想知道是否有任何其他js庫與jquery衝突。 –

+0

你使用這個http://malsup.com/jquery/form/?我的猜測是,您尚未導入您嘗試使用的插件/庫的JavaScript文件。 –

+0

這裏工作正常http://jsfiddle.net/m87s4/ –

回答

相關問題