0

Hi,
I can pass an array through jquery ajax.

var regSubCodeArray = new Array();
var temp = 9;
var i;

for(i=0;i<temp;i++)
	{
		subname = 'sub'+i;
		subcode = 'sub_code'+i;
		subcredit = 'sub_credit'+i;
		regSubCodeArray[i] = document.getElementById(subcode).innerText;

	}
 $.ajax({
		url: "testArray.php",	
		type: "GET",		
		data: "page="+regSubCodeArray,	
		cache: false,
		success: function (html) {	
		
			$('#ttl').html(html);	
		}		
	});

In 'testArray.php', i did the following

echo $_GET['page'];

It prints all the data of the array. But i want to access each data using some foreach loop in my testArray.php page.

Can any-one help me??

2
Contributors
7
Replies
15
Views
6 Years
Discussion Span
Last Post by pritaeas
0

What does $_GET['page'] look like? If you use a separator then you can use explode() to separate it.

My regSubCodeArray contains '1','2','3'......

for

echo $_GET['page'];

it prints the following

1,2,3,4,....
  all are separated by a comma
0
$regSubCodeArray = explode(',', $_GET['page']);
print_r($regSubCodeArray);

thnxx man...it worked...:)

0

Please mark this thread solved.

I have clicked the Mark this Thread as Solved under Has this thread been answered? but still its showing Discussion Thread
Unsolved

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.