Home  >  Article  >  Backend Development  >  Is there a way in jquery to determine whether the result of a form submission is successful or unsuccessful?

Is there a way in jquery to determine whether the result of a form submission is successful or unsuccessful?

WBOY
WBOYOriginal
2016-08-04 09:19:301430browse

The specific thing is this. When I was working on a project today, I used the layer pop-up plug-in. What I popped up was an iframe layer. I used ajax submission, and used the callback after ajax submission to determine whether the submission was successful. If successful, call parent.layer.close(index); close the pop-up box and refresh the current page outside to get the latest data.

But here comes the problem. Now I need to add a form verification. I plan to use jquery validate for verification, but when I submit it, I use ajax without going through the form tag. So I would like to ask if there is any way to determine whether the result of a form submission is successful or unsuccessful

Form:

<code class="html">        <div class="ibox-content">
            <div class="col-md-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">用户组名称:</label>
                    <div class="col-sm-9">
                        <input id='name' name="name" class="form-control" placeholder="用户组名称"
                            type="text" value="{$info.name}"> <span
                            class="help-block m-b-none id='user_help' ">输入用户组名称,不能少于3个字</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">所属上级组名称 :</label>
                    <div class="col-sm-9">
                        <select class="form-control" name="pid[]" id='pid'>
                            {$a}
                        </select> <span class="help-block m-b-none">请下拉选择该分组的所属上级,若该分组没有所属上级,则选择最上级</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-6 control-label">组详细说明:</label>
                    <div class="col-sm-6">
                        <textarea id='description' name="description" placeholder="输入组详细说明"
                            style="height: 120px; width: 640px">{$info.description}</textarea>
                    </div>
                </div>
                <input type="hidden" id='id' name="id" value="{$info.id}">
                <button class="btn btn-primary" id='button'>提交</button>
            </div>
        </div>

js ajax提交</code>