Reputation: 2367
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.
Upvotes: 0
Views: 71
Reputation: 17576
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.
Upvotes: 3
Reputation: 338208
$('div#tab2').load( 'morefour.php?title=' + encodeURIComponent(ktitle) );
Upvotes: 3
Reputation: 522081
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
.
Upvotes: 1