jQuery 使用ajax,并刷新页面

 1     <script>
 2         function del_product_information(id) {
 3             $.ajax({
 4                 url: "{% url 'del_product_information' %}",   //请求的URL
 5                 type: "GET",            //请求的方式
 6                 dataType: 'json',     // 前后端交互的数据格式
 7                 data: {'product_id': id}, //向后端发送的数据 
 8                 async: false,           //是否异步
 9                 success: function (msg) {   //请求成功后执行的操作
10                     alert(msg);
11                     window.location.reload()  //刷新页面
12                 }
13             })
14         }
15     </script>    

 如果是提交表单时,可以通过$('#update_form').serialize(),直接打包提交。

 
posted @ 2018-12-20 10:06  xsan  阅读(13865)  评论(0编辑  收藏  举报