使用脚本将内容发送到另一个页面

I have written a code in script which is given below.

function myFunction(a) {
  var k=a;
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
     if (this.readyState == 4 && this.status == 200) {
         document.getElementById("ques").innerHTML = this.responseText;
     }
  };
  xhttp.open("GET", "retrieveQuestion.php?question=" +a, true);
  xhttp.send();
  var q="<td><input type='text' name='answer' id='ans' placeholder='submit your answer here'/></td>" ;
  document.getElementById("t2").innerHTML=q;
  var answ = document.getElementById("ans").value;
  var z="<td align='center'><input type='button' value='submit' onclick='myfunc1(k,answ)'/></td>";
  document.getElementById("t3").innerHTML=z;
}

function myfunc1(q1,a1)
{
  xhttp.open("GET", "checkanswer.php?question=" +q1 + "&a1=" +a1, true);
  xhttp.send();
}

Now when i click on submit button it did not redirected to checkanswer.php can anyone help me in this problem.

Using xhttp.open is sending a background request to checkanswer.php, rather than actually redirecting to it. You'd need to use something like window.location instead.