1

当我尝试将 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>
4

1 回答 1

2

您的代码对我有用... http://dev.orangedigital.com.au/test/stack/2013-04-17/

我还必须为 ajaxSubmit 方法添加 jQuery Form 插件:http: //jquery.malsup.com/form/

于 2013-04-17T00:40:09.033 回答