Any idea why this code:
$('body').on('click', 'a.friend' , function(e){
e.preventDefault();
overlayerOn();
var $uid = $(this).attr("href");
var $br = $('#board');
$br.css('display', 'block');
$('#board').load("messages.php?uid=" + $uid);
});
Is not sending anything in …php?uid= ?
here is php script(but so far there is nothing just trying to receive the variable):
$id = $_REQUEST['uid'];
echo "<div id='hovno'>" . $id . "</div>";
And every time I receive only empty div tags.
but when it’s like this:
$('body').on('click', 'a.friend' , function(e){
e.preventDefault();
overlayerOn();
var $uid = $(this).attr("href");
var $br = $('#board');
$br.css('display', 'block');
$('#board').text($uid);
});
It’s printing out actual correct value. Why it’s not able to pass it? Thank you
Your variable
$uidcontains an href, which is probably a URI of some sort. Encode it before sending it to PHP so it can be properly retrieved from$_GET.Update
After seeing the PHP posted, I’ll just add that when you are passing a value directly from the HTTP request to PHP output, you should escape it against cross-site scripting attacks.