AJAX reload page with POST

前端 未结 4 1851
眼角桃花
眼角桃花 2020-12-18 20:20

Can anybody tell me how to refresh the current page with JavaScript, having a POST variable modified or added?

To be clear, I want to set some POST variables prior t

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-18 20:25

    If you want to refresh the entire page, it makes no sense to use AJAX. Use normal Javascript to post the form element in that page. Make sure the form submits to the same page, or that the form submits to a page which then redirects back to that page

    Javascript to be used (always in myForm.php):

    function submitform()
    {
      document.getElementById('myForm').submit();
    }
    

    Suppose your form is on myForm.php: Method 1:

    ...

    Method 2:

    myForm.php:

    ...

    myFormActor.php:

    
    

提交回复
热议问题