修改头像选中图片后,没有反应?修改密码按钮没有反应?好像POST请求都没发出去
来源:10-4 修改密码和修改头像1
zjuPeco
2017-05-07
usercenter-info.html中修改头像部分的FORM
<form class="clearfix" id="jsAvatarForm" enctype="multipart/form-data" autocomplete="off" method="post" action="{% url 'users:image_upload' %}" target='frameFile'> <label class="changearea" for="avatarUp"> <span id="avatardiv" class="pic"> <img width="100" height="100" class="js-img-show" id="avatarShow" src="{{ MEDIA_URL }}{{ request.user.image }}"/> </span> <span class="fl upload-inp-box" style="margin-left:70px;"> <span class="button btn-green btn-w100" id="jsAvatarBtn">修改头像</span> <input type="file" name="image" id="avatarUp" class="js-img-up"/> </span> </label> <input type='hidden' name='csrfmiddlewaretoken' value='799Y6iPeEDNSGvrTu3noBrO4MBLv6enY' /> {% csrf_token %} </form>
users中urls中的配置
urlpatterns = [ #用户信息 url(r'^info/$', UserinfoView.as_view(), name="user_info"), #用户头像上传 url(r'^image/upload/$', UploadImageView.as_view(), name="image_upload"), #个人用户中心修改密码 url(r'^update/pwd/$', UpdatePwdView.as_view(), name="update_pwd"), ]
users中Vieww的配置
class UploadImageView(LoginRequiredMixin, View): """ 用户修改头像 """ def post(self, request): image_form = UploadImageForm(request.POST, request.FILES, instance=request.user) if image_form.is_valid(): image_form.save() return HttpResponse('{"status":"success", "msg":""}', content_type='application/json') else: return HttpResponse('{"status":"fail", "msg":""}', content_type='application/json')
打断点上传头像,反应都没有,感觉没发出POST请求?但是好像没有配置错啊?
5回答
-
f12看一下点击头像后 有没有发起网络请求, 确定一下是没有发起网络请求还是后台view里面是500错误
你给我发一下消息 把你的源码发给我看看为什么点击修改密码没有反应, 应该是前端js的问题
022019-03-21 -
smart_leizi
2017-08-15
没有反应的原因是:
usercenter-base.html中的js代码没有起作用,修改成如下的样式就可以了
<script src="{% static 'js/selectUi.js' %}" type='text/javascript'></script>
<script type="text/javascript" src="{% static 'js/plugins/laydate/laydate.js' %}"></script>
<script src="{% static 'js/plugins/layer/layer.js' %}"></script>
<script src="{% static 'js/plugins/queryCity/js/public.js' %}" type="text/javascript"></script>
<script src="{% static 'js/unslider.js' %}" type="text/javascript"></script>
<script src="{% static 'js/plugins/jquery.scrollLoading.js' %}" type="text/javascript"></script>
<script src="{% static 'js/validateDialog.js' %}" type="text/javascript"></script>
<script src="{% static 'js/deco-common.js' %}" type="text/javascript"></script>
<script src="{% static 'js/plugins/jquery.upload.js' %}" type='text/javascript'></script>
<script src="{% static 'js/validate.js' %}" type="text/javascript"></script>
<script src="{% static 'js/deco-user.js' %}"></script>512019-03-21 -
慕盖茨8129089
2018-07-18
请问解决了吗
00 -
皮特__
2018-06-20
。。。。
00 -
HotDeath
2017-05-07
把后台的截屏发上来
00
相似问题