I have an anchor tag in a page1.html which has an onClick event . This onClick makes a REST API call. The response of this REST API call is then passed to a javascript function , which loads page2.html and an input box on page 2 needs to be populated with the responses value.
Here is the code which loads the new page and tries to populate the input box present on the new page
function(response){
document.location="page2.html";
$( "#inputBoxID" ).val( response.text );
}
The above code is not populating the input box with id "inputBoxID" present in page2.html. What could be the reason and possible solution?
document.location="page2.html";you know that makes the browser navigate away from the current page, right? Any js after that call should not be relied upon to execute since the page is unloadingdocument.location = "other_page.html"