Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How to pass js array to php file

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

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
mayur288
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sun Feb 24, 2013 3:00 am

Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.