当我尝试将ajaxSubmit添加到我的表单时,我收到错误“Uncaught TypeError:Object [object Object]没有方法'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>
答案 0 :(得分:2)
您的代码对我有用...... http://dev.orangedigital.com.au/test/stack/2013-04-17/
我还必须为ajaxSubmit方法添加jQuery Form插件:http://jquery.malsup.com/form/