修改资料无反应

来源:13-3 修改个人信息

Hanamichi520

2020-09-05

老师,修改昵称、性别和生日后,点击保存无反应

浏览器报如下错:

deco-user.js:257 Uncaught ReferenceError: verify is not defined
    at HTMLDocument.<anonymous> (deco-user.js:257)
    at j ((index):2)
    at Object.fireWith [as resolveWith] ((index):2)
    at Function.ready ((index):2)
    at HTMLDocument.J ((index):2)


  verify(
		[{
			id: '#nick_name',
			tips: Dml.Msg.epNickName,
			require: true
		}]

HTML页面代码如下:

    <form class="perinform" id="jsEditUserForm" autocomplete="off">
                <ul class="right">
                    <li>昵&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称:
                        <input type="text" name="nick_name" id="nick_name"
                               value="{{ user.nick_name|default_if_none:'' }}" maxlength="10">
                        <i class="error-tips"></i>
                    </li>
                    <li>生&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日:
                        <input type="text" id="birth_day" name="birday" value="{{ user.birday|default_if_none:''|date:'Y-m-d' }}"
                               readonly="readonly"/>
                        <i class="error-tips"></i>
                    </li>
                    <li>性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别:
                        <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" name="gender" value="male"
                                   {% if user.gender == 'male' %}checked="checked" {% endif %}>男</label>
                        <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="radio" name="gender" value="female" {% if user.gender == 'female' %}checked="checked" {% endif %}>女</label>
                    </li>
                    <li class="p_infor_city">地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址:
                        <input type="text" name="address" id="address" placeholder="请输入你的地址" value="{{ user.address }}"
                               maxlength="10">
                        <i class="error-tips"></i>

JS代码如下:

	  verify(
	        [{
	            id: '#nick_name',
	            tips: Dml.Msg.epNickName,
	            require: true
	        }]
	    );
	    //保存个人资料
	    $('#jsEditUserBtn').on('click', function () {
	        var _self = $(this),
	            $jsEditUserForm = $('#jsEditUserForm')
	        verify = verifySubmit(
	            [
	                {id: '#nick_name', tips: Dml.Msg.epNickName, require: true},
	                {id: '#birth_day', tips: Dml.Msg.epBirthday, require: true}
	            ]
	        );
	        if (!verify) {
	            return;
	        }
	        $.ajax({
	            cache: false,
	            type: 'post',
	            dataType: 'json',
	            url: "/users/info/",
	            data: $jsEditUserForm.serialize(),
	            async: true,
	            beforeSend: function (XMLHttpRequest) {
	                _self.val("保存中...");
	                _self.attr('disabled', true);
	            },
	            success: function (data) {
	                if (data.nick_name) {
	                    _showValidateError($('#nick_name'), data.nick_name);
	                } else if (data.birday) {
	                    _showValidateError($('#birth_day'), data.birday);
	                } else if (data.address) {
	                    _showValidateError($('#address'), data.address);
	                } else if (data.status == "fail") {
	                    Dml.fun.showTipsDialog({
	                        title: '保存失败',
	                        h2: data.msg
	                    });
	                } else if (data.status == "success") {
	                    Dml.fun.showTipsDialog({
	                        title: '保存成功',
	                        h2: '个人信息修改成功!'
	                    });
	                    setTimeout(function () {
	                        window.location.href = window.location.href;
	                    }, 1500);
	                }
	            },
	            complete: function (XMLHttpRequest) {
	                _self.val("保存");
	                _self.removeAttr("disabled");
	            }
	        });
	    });
	});

能帮我看看是那里有问题吗?

写回答

1回答

Hanamichi520

提问者

2020-09-05

找原因了,有一个js文件引入的文件名写错了

0
3
bobby
回复
小郎先森
你留个qq 我加你看看
2023-04-14
共3条回复

Django+ xadmin 开发在线教育网站

一套通用的技术组合拳,助你解决大部分Python类网站后端问题

1911 学习 · 2149 问题

查看课程