开发者

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开发者_如何学Go 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


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.


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});


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜