Wayne
Wayne

Reputation: 25

sending more than one variable with .load in jquery

In relation to the topic posted here: sending more than one variable with .load in jquery

I have a similar issue, I pass my variables to a php file which then looks to retrieve the variable's values.

(I will just post the main bits for now) My line of code reads:

$('#step').load("profile/changealbumcover.inc.php", {'album': album, 'image': image});

In my php file i have:

$album = $_GET['album']; $image = $_GET['image']; 

This returns blank variable values so I tried:

$('#step').load("profile/changealbumcover.inc.php", {'?album=': album, '&image=': image});

This also returns blank variable values.

Can anyone tell me where I am going wrong?

Thanks in advance

Wayne

Upvotes: 0

Views: 221

Answers (3)

ShankarSangoli
ShankarSangoli

Reputation: 69905

If you use load method along with data then POST method is used to send the data. I think you should use $_POST in your php code to retreive the values. And use the below js this is correct.

$('#step').load("profile/changealbumcover.inc.php", {'album=': album, 'image=': image});

Upvotes: 0

Luke Stevenson
Luke Stevenson

Reputation: 10341

To send the variables through $_GET[], use the following, and compile the full URL to call the page:

$('#step').load("profile/changealbumcover.inc.php?album="+album+"&image="+image);

Upvotes: 0

Uoli
Uoli

Reputation: 93

You are passing the data as an Object (inline object).

When you use Objects as a data source, JQuery will send the data as POST data.

In your PHP code just change the $_GET to $_POST, and will probably work.

If you would like to use GET, just pass the data as a string.

Upvotes: 1

Related Questions