【发布时间】:2011-11-05 13:59:51
【问题描述】:
JPagination 无法将<div> 与<li> 分页。我不知道这是否是ID冲突,或者它是否是PHP,或者这里到底发生了什么,我希望有人能帮我弄清楚发生了什么。
所以这就是我得到的。首先,这是我的 HTML。这是我正在做的一个页面,它会将你的文本“发布”到墙上(这是一个<div> 和一个<ul>)。这是 HTML 正文:
<div id="head">
<form name="postbar_add_post" id="postbar_add_post" method="post">
<fieldset>
<legend>What are you doing now? ...</legend>
<input type="text" name="addcontentbox" id="addcontentbox" maxlength="200" />
<input type="submit" name="addpost" value="Submit" class="submit" />
</fieldset>
</form>
</div>
<div id="cuerpo"><ul id="wall"></ul></div>
好的,所以,在文档的开头,我调用了 jQuery,还有一个名为 JPagination 的插件,并且在开头我还得到了一个脚本,它可以让内容“贴到墙上”只是为了确保我做对了,这是我在文件头上得到的内容:
<script src="http://c.fzilla.com/1286136086-jquery.js"></script>
<script src="http://c.fzilla.com/1291523190-jpaginate.js"></script>
// This is the script to post whats typed on the input to the div called wall:
<script type="text/javascript">
$.noConflict();
jQuery(document).ready(function(){
jQuery("form#postbar_add_post").submit(function() {
var addcontentbox = jQuery('#addcontentbox').attr('value');
if ( addcontentbox.replace(/\s/g,"") == "" ) return false;
jQuery.ajax({
type: "POST",
url: "postear.php",
data:"addcontentbox="+ addcontentbox,
success: function(){
jQuery("ul#wall").prepend("<li>"+addcontentbox+"</li>");
jQuery("ul#wall li:first").fadeIn();
document.postbar_add_post.addcontentbox.value='';
document.postbar_add_post.addcontentbox.focus();
}
});
return false;
});
});
</script>
// and this would be where I try to paginate the content
<script type="text/javascript">
$(document).ready(function() {
$("#wall").jPaginate();
});
</script>
所以,发帖效果很好!但是分页永远不会发生,如果我更改函数以将其应用于父 <div>,则不会发生任何事情,它保持不变。在从 jQuery 添加“noconflict”之前,它甚至不起作用。
以防万一,我将 PHP 的第一个函数调用留在这里:
<?php
if( isset($_POST['addcontentbox']))
{
// Connection to Database
include('config.php');
// NO Query Injection
$message = mysql_real_escape_string($_POST['addcontentbox']);
// echo
$sql = 'INSERT INTO WALL (message) VALUES( "'.$message.'")';
mysql_query($sql);
echo $message;
}
else
{
echo '0';
}
?>
我们将不胜感激任何指导或任何类型的解决方案。
【问题讨论】:
标签: php javascript jquery database conflict