Note that there are some explanatory texts on larger screens.

plurals
  1. POForm submission after dynamically adding new fields
    primarykey
    data
    text
    <p>I have a form for eg.</p> <p><strong>HTML</strong></p> <pre><code>&lt;form id="data"&gt; &lt;input id="hostname" type="text" name="hostname" value="" /&gt; &lt;/form&gt; </code></pre> <p>And i have some javascript that adds more fields to the no. of friends i have.</p> <p>Note: i will avoid adding some of the fb api scripts to save my writing time. add a comment if you want me to re-edit and add it.</p> <p><strong>JAVASCRIPT</strong></p> <pre><code>&lt;script&gt; //load fb api //authenticate with permissions {scope: email,friends_birthday,users_birthday} FB.api('/me/friends?fields=id,name,birthday',function (friendsdata) { for (var i = 0; i &lt; friendsdata.data.length; i++) { $('#hostname').after('&lt;input type="text" name="hostid[]" value="'+friendsdata.data[i].id+'" /&gt;'); } $.ajax({ type: "GET", url: "php/send.php", data: $("#data").serializeArray(), success: function(send) { console.log(send); } }); }) &lt;/script&gt; </code></pre> <p><strong>PHP</strong></p> <pre><code>$hostid = $_GET['hostid']; print_r($hostid); // returns nothing if input field is generated using jquery after </code></pre> <p>The above works perfectly fine. it retrieves the data and inserts in into the fields. But the problem is when i'm trying to post this data to a php file via ajax using serialize array.</p> <p>I cannot receive ids array in php due to dynamic generation of the input fields.</p> <p>if i simply add the id field manually it works fine.</p> <p>Any Suggestions or solutions ? </p> <p><strong>EDITS</strong></p> <p>Ajax save method as requested by Arun.</p> <p>Regards, Dalton.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload