jQuery `submit` method ignores POST sends with GET. Why?

前端 未结 1 600
既然无缘
既然无缘 2021-01-19 16:19

I have a form like this.

1条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-19 16:59

    As discussed in comments, there is no bug, at least on the last version of jQuery 2.0.3, one can test with this:

    
    
    
    
    
    
    
     0) {
      echo "";
    }
    
    if(count($_POST) > 0) {
    echo "";
    }
    ?>
    
    
      
    
    
    
    Click me to Do jQuery Submit

    When one clicks on gold background text, $("#hiddenForm").submit(); is used to submit the form.

    Here is the output:

    Submitted with method=POST: $_POST:
    array(1) {
      ["HiddenFormInput"]=>
        string(0) ""
    }
    

    In your original form, no URL arguments are passed by the submitting, as only inputs with name attribute specified are submitted. So I added the attribute name="HiddenFormInput" for your hidden input.

    0 讨论(0)
提交回复
热议问题