Redirecting to a page after submitting form in HTML

前端 未结 3 1726
轮回少年
轮回少年 2020-12-30 03:14

I\'m fairly new to coding in HTML. After hours of searching the internet for a way to do this, I failed and so I\'m here. I was setting up a CSRF Proof of concept page here,

3条回答
  •  滥情空心
    2020-12-30 03:31

    You need to use the jQuery AJAX or XMLHttpRequest() for post the data to the server. After data posting you can redirect your page to another page by window.location.href.

    Example:

     var xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
          window.location.href = 'https://website.com/my-account';
        }
      };
      xhttp.open("POST", "demo_post.asp", true);
      xhttp.send();
    

提交回复
热议问题