0

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)

2
  • Do you need POST request or GET is fine? Commented Feb 27, 2014 at 8:33
  • then you can just change location: location = "script.py" Commented Feb 27, 2014 at 8:39

2 Answers 2

2

Try something like this:

window.location.replace("http://example.com");

or this:

window.location.href = "http://example.com";
Sign up to request clarification or add additional context in comments.

Comments

0

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();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.