Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to pass an arrray in PHP via Ajax

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 71
    Comment on it

    Hello Readers if you want to send the array into another PHP page then you can use the code below:-

    I have array made by function .push. In array is very large data. How is the best way send this to PHP script?

     dataString = array(a->b); // array
       $.ajax({
            type: "POST",
            url: "script.php",
            data: dataString, 
            cache: false,
    
            success: function(){
                alert("OK");
            }
        });
    

    Now Create a file script.php and paste the following code to get it.

       $data = $_POST['data'];
    
          // here i would like use foreach:
    
          foreach($data as $d){
             echo $d;
          }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: