📜  django ajax 重定向到成功视图 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:53.152000             🧑  作者: Mango

代码示例1
$.post( "{% url 'your_url' %}", 
         { csrfmiddlewaretoken: '{{ csrf_token}}' , 
           other_params: JSON.stringify(whatever)
         },  
         function(data) {
             if(data.status == 1){ // meaning that everyhting went ok
                // do something
                   window.location('your_url')
             }
             else{
                alert(data.message)
                // do your redirect
                window.location('your_url')
             }
        });