2015-06-29 76 views
3

我使用聚合物初學者工具包1.0.2,我試圖根據我發現的(小)文檔使用鐵形式。發送POST方法和聚合物鐵形式?

我的方法形式是「後」,只包含一個輸入。

我的形式 「行動」 是一個PHP腳本(add.php)顯示的$ _GET內容和$ _ POST:

print_r($_POST); 
print_r($_GET); 

我的表單組件(form_eclp.html)是:

<dom-module id="my-form"> 
    <template> 
     <div class="horizontal center-center layout"> 
      <div> 
       <div class="horizontal-section"> 
        <form is="iron-form" id="formGet" method="post" action="add.php"> 
         <paper-input name="name" label="Name" required></paper-input> 
         <br><br><br> 
         <paper-button raised onclick="clickHandler(event)">Submit</paper-button> 
        </form> 
       </div> 
      </div> 
     </div> 
    </template> 
    <script> 

     function clickHandler(event) { 
      Polymer.dom(event).localTarget.parentElement.submit(); 
     } 

     Polymer({ 
      is: 'my-form', 
      listeners: { 
       'iron-form-response': 'formResponse' 
      }, 
      formResponse: function(e) { 
       // ????????? 
      } 
     }); 
    </script> 
</dom-module> 

我打電話,如果來自:

<link rel="import" href="form_eclp.html"> 
<my-form></my-form> 

當我進入名稱輸入文本「測試」後,點擊提交按鈕,我可以在網絡中的TA看到?的瀏覽器developper工具,它是一個POST請求,OK,但是URL是add.php名稱=測試,並在響應選項卡,我有B:

Array 
(
) 
Array 
(
    [name] => test 
) 

根據我的表單操作(add.php腳本),第一個數組是$ _POST,第二個$ _GET。

我可以看到,儘管form method =「post」,它是一個「get」請求,因爲只填充了$ _GET,$ _POST中沒有任何內容。

我不明白,這是一個錯誤?

回答

1

所以它看起來像表單輸入已經過時在你的bower.json。做到這一點:涼亭安裝-S PolymerElements /鐵形式,一切都應該罰款。

+0

好的,它的工作原理非常感謝。 – krazitchek

+0

不適合我 – Donearh

+0

謝謝。你爲我節省了無數小時的研究!已經搞亂了太久。我確實做了'更新更新'。這是不是做同樣的事情? – Rijul

0

這不是一個答案,但因爲我不能評論我不得不在這裏問這個。你有沒有試圖用鐵形式將任何東西放入數據庫中?我一直試圖從幾個$ _POST的數據到數據庫,並沒有任何運氣。