How to pass js array to php file

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

mayur288
New php-forum User
New php-forum User
Posts: 2
Joined: Sun Feb 24, 2013 3:00 am

How to pass js array to php file

Postby mayur288 » Sun Feb 24, 2013 3:43 am

i don't know how to pass js array to php file using ajax?

my array is :

var arr= new Array();

with suppose these values : id, price, quantity like
arr.push([1,200,3]);
arr.push([1,200,3]);
arr.push([1,200,3]);
arr.push([1,200,3]);

this is my js code on submit :

Code: Select all

$("form").submit(function(){
      $.ajax({
         type : 'GET',
         url : 'code/GetData.class.php',
         data : {arr : arrItemsList},
         cache : false,
         success : function(data) {
            if(data){
               return true; //will navigate to next page
            }
            else{
               return false; // on data false nothing will happen
            }
         }
      });
   });

Tell me if there is any thing wrong in js.

now want to know how do I acceess arr in php code

GetData.class.php file code :

Code: Select all

<?php
/*................code for accessing array variable arr.........*/
?>


thanks in advance

Return to “PHP coding => General”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest