I want to redirect user to another route if the code matches depending upon the values returned in the ajax success. Its working great now How do I write the script to redirect to the next route like redirect in php.
AJAX to check the code matches and its working great. What next
<script>
$("#codeModal form").submit(function(event) {
event.preventDefault();
var codetyped=$(this).find(".codeinput").val();
$.ajax({
type:"post",
url:"{{request.route_url('testingajax')}}",
data:{'codetyped':codetyped},
success:function(res){
alert(res);
}
});
});
</script>
Here is the view config
@view_config(route_name='testingajax', renderer='json')
def hello(request):
# return request.session['secretcode']
# return request.params.get('codetyped')
if int(request.params.get('codetyped')) == request.session['secretcode']:
return 'Success'
else:
return 'Error'