首页 > Web开发 > 详细

django 使用jquery ajax post数据问题

时间:2015-10-15 12:37:02      阅读:245      评论:0      收藏:0      [点我收藏+]

django 开启了CSRF功能导致jquery ajax post数据报错

解决方法在post数据里引入csrfmiddlewaretoken: {{ csrf_token }}},同时需要在form表单中设置{% csrf_token %}


<script src="/static/jquery/dist/jquery.min.js"></script>
                  <script>
                       $(function(){
                            $("#postset").click(function() {
                                $.post("", {newpasswd1: "John", newpasswd2: "John",csrfmiddlewaretoken: {{ csrf_token }}},function (data) {
                                            alert("Data Loaded: " + data);
                                        });
                            });
                        });
                  </script>

 

 

 

django 使用jquery ajax post数据问题

原文:http://www.cnblogs.com/LD-linux/p/4881834.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!