'Send user to a new page via JS [duplicate]

We are submitting data and then showing the result in a a alert box, what we want to do is send the user to a another page(response.php?r=result) instead of showing the alert.

The code we are using is below

function (result) {
            
                    setTimeout(function() {
                        alert("We got a barcode\n" +
                              "Result: " + result.text + "\n" +
                              "Format: " + result.format + "\n" +
                              "Cancelled: " + result.cancelled);                            
                    }, 0);
                },


Solution 1:[1]

How about something like that

location.href = 'response.php?r=' + JSON.stringify(result);

?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Norman