Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

seventeen

macrumors member
Original poster
Apr 9, 2009
41
0
Denton, Tx
so i am messing around with jquery's .load(). I'm sending an array of parameters to a php script to be executed like so:

Code:
$(document).ready(function() {
	$('#result').load('test.php', { 'params[]': ["<?php echo $params[0]; ?>", "<?php echo $params[1]; ?>"] });
});

the problem is, how to i retrieve this 'param' array within my php script? is it sending a post request, so could i get it like $_POST['param'] or something?

thanks
 
You'll want to send parameter pairs, just like you see in a GET method:
Code:
["param1=something", "param2=otheritem"]
Then in PHP like you would guess,
PHP:
$param1 = $_POST['param1'];
$param2 = $_POST['param2'];
I was recently working on some AJAX and ran into the same question.
 
Thanks, while I was waiting for your reply yesterday I went ahead and just set it up to work without the array in much the same way as you suggested.

But I've run into another problem. It appears none of the while and/or for loops in the php script are executing...

I threw in some 'debugging' echos to see where I was losing my variable values. and yeah, it looks like my loops are just being totally ignored.

Any idea on why something like this might be happening?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.