0

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

0

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

3 Comments

You don't include the "?" or "&" characters in the data element for a jQuery load() action - api.jquery.com/load
@Locanos - Sorry that was a copy paste problem I changed it. Please remove my down vote :(
RESOLVED: I used the $_POST method in my php file and used the below code to pass the variables $('#step').load("profile/changealbumcover.inc.php", {'album': album, 'image': image});
0

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

2 Comments

Tried that but when i sent more than 1 variable both their values were empty. If I sent 1 variable via the above method it was fine.
Have you tried checking what the line compiles as using console.log() and Firefox/Firebug, Web Inspector/Safari, or similar? ie console.log("profile/changealbumcover.inc.php?album="+album+"&image="+image);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.