当我尝试将 ajaxSubmit 添加到我的表单时,我收到错误“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>