the problem is that when i click a href and target a jquery function the code executed normally but the page moves on top always….
the javascript code:
[code=php]
<script type=”text/javascript”>
$(document).ready(function(){
$(‘.wallmore’).click(function (e){
var lastid = $(this).attr(“id”);
last_msg_funtion(lastid);
});
function last_msg_funtion(lastid){
$.ajax({
type: “POST”,
url: “<?php echo $root;?>includes/load.php”,
data: ‘lastid=’+lastid,
dataType: “html”,
success: function(msg){
$(msg).insertBefore(‘#last_msg_loader’);
}
});
}
});
</script>
and the load.php is:
[code=php]
<?php
include_once “../myconnect.php”;
function loadmember ($gallery, $isdefault, $img_type){
$root = “http://”.$_SERVER[‘HTTP_HOST’].”/”;
if($isdefault==’yes’){
$default=mysql_fetch_array(mysql_query(“select * from sbrecipe_def_image where sbdef_image_id=”.$gallery.””));
return “”.$root.”uploadimages/default/”.$default[“cat_image”].””;
}
elseif($isdefault==’no’){
$query_images = mysql_fetch_array(mysql_query(“select * from sbrecipe_images where sbimages_id=”.$gallery.””));
switch ($img_type){
case “0”:
return $root.”uploadimages/”.$query_images[“sb_image_url”];
break;
case “1”:
return $root.”uploadimages/”.$query_images[“sb_thumb”];
break;
case “2”:
return $root.”uploadimages/”.$query_images[“sb_thumb2”];
break;
case “3”:
return $root.”uploadimages/”.$query_images[“sb_thumb3”];
break;
}
}else{
}
}
?>
<?php
if($_POST[‘lastid’]){
$last_msg_id=$_POST[‘lastid’];
$sql=mysql_query(“SELECT * FROM comments WHERE id < ‘$last_msg_id’ ORDER BY id DESC LIMIT 1″);
$last_msg_id=””;
while($row=mysql_fetch_array($sql)){
$user=mysql_fetch_array(mysql_query(“select * from sbrecipe_members where sb_id=”.$row[‘user’].””));
$msgID= $row[‘id’];
?>
<div class=”comment” id=”<?php echo $msgID; ?>”>
<div class=”avatar”>
<img src=”<?php echo loadmember( $user[“sb_member_image”], $user[“sb_member_isdefault”], ‘2’); ?>” />
</div>
<div class=”name”><?php echo $user[“sb_username”]; ?></div>
<div class=”date” title=”Added at <?php echo date(‘H:i on d M Y’,$row[‘dt’]); ?>”><?php echo date(‘d M Y’,$row[‘dt’]); ?></div>
<p><?php echo $row[‘body’]; ?></p>
</div>
<?php
}
}
?>
<script type=”text/javascript”>
$(document).ready(function(){
jQuery(‘.wallmore’).attr(“id”, “<?php echo $msgID; ?>”);
});
</script>
is anyboby tell me why this is happening and give me a solution???…thanks in advance….