Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

django ajax redirect to a view on success

$.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')
             }
        });
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #django #ajax #redirect #view #success
ADD COMMENT
Topic
Name
4+7 =