Js is used to transfer data from one page to another through url

  • 2020-03-30 03:47:53
  • OfStack

Using js to transfer data from one page to another.

If you want to upload to a new page, which language is your website based on

Pass a parameter through the url

If it's an HTML page, then JS goes to a new page, window.location.href='a. HTML ? Id = 100 '; Then JS on the a.html page < Div id = "s" > < / div>


<script>
document.getElementById("s").innerHTML=window.location.split('?')[1];
</script>

AJAX is used if you want to implement AJAX to pass parameters from page a to page b and display the results of executing parameters from page b in the layer of page a

It's too much to write. It's for JQUERY


<div id="a"></div>
$("#a").load("b.html?id=100");
// or 
$.get("b.html?id=100",function(data){
$("#a").html(data);
})

There's also the POST method, which I'm not going to list here


Related articles: