我有任何页面,并包括jQuery库和CSS(this)。jquery库不能在外部php文件中工作
现在我有代码为Twitter像加载更多。这工作,但当我需要删除这使用jQuery它不起作用(与我的索引中的另一个代码)。问题是:jQuery库不会附加到外部的php文件。
我在colorbox中有同样的问题。当我在colorbox中加载iframe时,我的索引jQuery不会附加到外部文件,所以我将手动jQuery添加到外部文件!
有没有办法只使用jquery原始文件(我的索引)?
EX JS负载更多:
<script type="text/javascript">
$(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: "ajax_more.php",
data: "lastmsg="+ ID,
cache: false,
success: function(html){
$("ol#updates").append(html);
$("#more"+ID).remove();
}
});
}
else
{
$(".morebox").html('The End');
}
return false;
});
});
</script>
PHP:
<?php
include("config.php");
if(isSet($_POST['lastmsg']))
{
$lastmsg=$_POST['lastmsg'];
$result=mysql_query("select * from messages where msg_id<'$lastmsg' order by msg_id desc limit 9");
$count=mysql_num_rows($result);
while($row=mysql_fetch_array($result))
{
$msg_id=$row['ms_gid'];
$message=$row['message'];
?>
<li>
<?php echo $message; ?>
</li>
<?php
}
?>
<div id="more<?php echo $msg_id; ?>" class="morebox">
<a href="#" id="<?php echo $msg_id; ?>" class="more">more</a>
</div>
<?php
}
?>
HTML:
<head><script type="text/javascript" src="./jquery.min.js"></script></head>
<div id='container'>
<ol class="timeline" id="updates">
<?php
$sql=mysql_query("select * from messages ORDER BY msg_id DESC LIMIT 9");
while($row=mysql_fetch_array($sql))
{
$msg_id=$row['msg_id'];
$message=$row['message'];
?>
<li>
<?php echo $message; ?>
</li>
<?php } ?>
</ol>
<div id="more<?php echo $msg_id; ?>" class="morebox">
<a href="#" class="more" id="<?php echo $msg_id; ?>">more</a>
</div>
</div>
你的问题缺乏清晰度。到目前为止,它似乎意味着你可以成功地在一个php文件中加载和使用jquery,但它不会自动提供给其他php文件。那是对的吗?没有更具体的例子和信息,向你提供有用的答案将是非常困难的。 – Vijay 2012-04-07 09:24:41
请参阅我的更新信息。这完全e.x – Gcoder 2012-04-07 09:35:57