Jump to content

php variable inside jquery


violinrocker

Recommended Posts

i used the code below and i want to put $session->username into url: "addons/functions/ajax_more.php", so that it would be like url: "addons/functions/ajax_more.php?name=$session->username", because the code i have in ajax_more.php requires $session->username... the only options i could think of is $_Post and $_get but i really dont know jquery.

 

$(function() {
//More Button

$('.more').live("click",function() 
{
var ID = $(this).attr("id");
if(ID)
{
$("#more"+ID).html('<img src="moreajax.gif" />');

$.ajax({
type: "POST",
url: "addons/functions/ajax_more.php",
data: "lastmsg="+ ID, 
data: "username="+ ID, 
cache: false,
success: function(html){
$("ol#updates").append(html);
$("#more"+ID).remove();
}
});
}
else
{
$(".morebox").html('The End');

}


return false;


});
});

 

this is whats inside ajax_more.php... at first i included a php file from which $session->username is from, but then it posts an error like session_start() [function.session-start]: Cannot send session cache limiter - headers already sent

 

if(isSet($_POST['lastmsg']))
{
$lastmsg=$_POST['lastmsg'];
$str = "SELECT *
FROM 
news_feed
  INNER JOIN friends ON news_feed.name = friends.friendname
WHERE friends.username = '$session->username' and id<'$lastmsg' ORDER BY date DESC LIMIT 10
";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.