0

I have this code right now :

$(document).ready(function() {
var ktitle =        $('.hiddentwo').text();
$('div#tab2').load('morefour.php?title=ktitle');
});  

but the php file doesn't seem to be getting this variable...am I doing something wrong?

I echo something in the php file and I see the text. Also when I echo the $ktitle in the php file I get 'kitle'...that should not be happening :p. This is a stupid question, but I just want to know how to store that variable in the url.

3 Answers 3

3
$('div#tab2').load( 'morefour.php?title=' + encodeURIComponent(ktitle) );
Sign up to request clarification or add additional context in comments.

Comments

3

try using

   $('div#tab2').load("morefour.php", {
       title:ktitle
   });

or

$('div#tab2').load('morefour.php?title='+ktitle);

UPDATE

In the first case, the data are passed to the script via POST, in the second via GET.

Comments

1

Because you're hardcoding the ?title to "ktitle". If you want to replace this with a variable, you need to concatenate the variable with 'morefour.php?title=' + ktitle.

Comments

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.