提交后重置ajax表单

时间:2017-10-26 19:48:30

标签: javascript jquery forms reset

$(document).ready(function() {
    $('form').submit(function(event) {
        var formData = {
            'text' 				: $('input[name=text]').val()
        };
        $.ajax({
            type 		: 'POST', // define the type of HTTP verb we want to use (POST for our form)
            url 		: 'class/sendchat.php', // the url where we want to POST
            data 		: formData, // our data object
            dataType 	: 'json', // what type of data do we expect back from the server
            encode 		: true
        })
        event.preventDefault();
    });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<form id="contact-forms" name="contact-form" action="#">
    <input name="text" type="text" placeholder="متن پیام" style="width: 90%; float: right;">
    <a class="write-link send" style="width: 10%; float: left;" onclick="submitForm()"></a>
    <input type="submit" class="hide">
</form>

我想在提交后重置我的。

如何在提交后重置输入[name = text]?

0 个答案:

没有答案