Reputation: 1056
I need to redirect to a different page when a JS process instantiated on the current one is complete. Problem is only JS knows when it is complete, and I'm using Python (Flask) as the web framework. I thought of creating a form element sort of like a "submit" button(which the Python app can listen for) and just sending that upon completion How can I go about this, or is there a better way?(I'm assuming it requires some jQuery magic)
Upvotes: 0
Views: 55
Reputation: 1010
Try something like this:
window.location.replace("http://example.com");
or this:
window.location.href = "http://example.com";
Upvotes: 2
Reputation: 5340
I use jQuery,
var url = '/..url to post..', dataMap = {
a : 1,
b : 2
};
//create a form
var $form = $('<form>').appendTo(document.body);
//set action, target, method
$form.attr({
action : url,
target : '_blank',
method : 'POST'
});
//create inputs,
for ( var k in dataMap) {
$('<input type="hidden" />').attr('name', k).val(dataMap[k]).appendTo($form);
}
$form.submit();
$form.remove();
Upvotes: 0