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(),直接打包提交。