0

I have dynamic Html Form Elements.

 <input type="text" name='myInputs[]'> 

And my Ajax request

 $.ajax({
            type:"POST",
            url:"./ajax/xxxxx.php",
            data:{ 'something': 'something'},
            success: function(data){

            }
        });

My Question is how can i get the inputs from all my from elements over Ajax to my PHP File ?

Thanks

Maddy S.
  • 87
  • 6

3 Answers3

1

you can use

data = $('#Form').serialize();
Rildo Gomez
  • 295
  • 6
  • 20
0

You can request the value of an input field via jquery by using $(name='nameOfFields').val();

If there are multiple fields with the same name this should return an array which you can use. Otherwise you can work with id's and make an array yourself.

Matsooh
  • 133
  • 6
0

in xxxx.php you just have $variable_name = $_POST['something'];

  <input type="text" class="myInputs" name="myInputs[]">

  $.ajax({
        type:"POST",
        url:"./ajax/myFile.php",
        data:{ 'something': $('.myInputs').val()},
        success: function(data){

        }
  });

here is myFile.php:

<?php
 print_r($_POST['something']; 
vimuth
  • 2,928
  • 13
  • 43
  • 73
futureweb
  • 397
  • 2
  • 12