javascript - form doesn't pass buttons value via jquery, why? -


i have written in php:

 echo '<form method="post" id="delete">';     while ($users = $getchildusers -> fetch_array()){         echo '<tr>';             echo '<td>'.$users['user_id'].'</td>';             echo '<td>'.$users['user_mail'].'</td>';             echo '<td>'.$users['user_phone'].'</td>';             echo '<td>';                     echo '<button type="submit" class="btn btn-primary" onclick="del_child_user();" name="user_id" value="'.$users['id'].'">usuń </button>';             echo '</td>';         echo '</tr>';     }     echo '</form>'; 

and used function:

function del_child_user(){ $(document).on('submit', '#delete', function() {     $.post('scripts/child_user.php', $(this).serialize(), function(data)     {         $("#del_msg").html(data);     });     return false; });} 

when try return value of $_post['user_id'], there no value display. when write print_r($_post), gives me empty array.

what doing wrong?

i say, definition wrong on button

you defined:

echo '<button type="submit" class="btn btn-primary" onclick="del_child_user();" name="user_id" value="'.**$users['id']**.'">usuń </button>';

but on top, wrote $users_['user_id']

maybe typo?

addition:

look here, created example reach goal without using forms.

https://jsfiddle.net/9zbt9h2k/6/


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -