How to redirect through 'POST' method using Javascript?

前端 未结 11 1129
说谎
说谎 2020-12-05 10:05

I\'ve queried and doesn\'t work out what I\'ve found. Is there any way to redirect to give url with POST method using Javascript or jquery?

11条回答
  •  情书的邮戳
    2020-12-05 10:29

    Here the idea is to send data to server while you redirect user to another webpage without using the GET method and maintaining a cosmetic appearance to your URL. So we are going to use the same procedure of sending a Form with POST method.

    HTML/Javascript code for creating the form and submitting it to server:

    
    
    
    
    
    

    Receiving this data in PHP:

    
    

    In this way, users will be redirected to receive.php with some data being informed in a POST method.

提交回复
热议问题