後端返回錯誤,前端僅刷新驗證碼的方式

驗證碼的輸入框及圖片代碼:【使用tp5的驗證碼】 

<!-- 驗證碼輸入框及圖片 -->
<div class="form-group">
                <div class="row">
                    <!-- /.col -->
                    <div class="col-xs-5">
                        <input type="text" class="form-control" name="captcha" maxlength="4" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')" placeholder="驗證碼" required>
                    </div>
                    <div class="col-xs-7">
                        <img onclick="this.src='{:captcha_src()}?'+Math.random()" id="captcha" src="{:captcha_src()}" alt="captcha"/>
                    </div>
                    <!-- /.col -->
                </div>
            </div>

js代碼:

$.ajax({
                url:'login',
                type:'post',
                data:form,
                success:function (data) {
                    if (data.status == 0) {
                        window.location.href = '/AuthBase.Index/index';
                    } else {
                        layer.msg(data.msg);
//刷新驗證碼
                        $("#captcha").attr("src","{:captcha_src()}?"+Math.random())
                        //定時器
                        isClick(data.data);
                    }
                },
                error:function (error) {
                    layer.msg(error);
                    isClick();
                }
            },'json');

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章