Php 与jQuery和JPagination冲突,JPagination无法正常工作
JPagination无法使用Php 与jQuery和JPagination冲突,JPagination无法正常工作,php,javascript,jquery,database,conflict,Php,Javascript,Jquery,Database,Conflict,JPagination无法使用对进行分页。我不知道这是否是ID上的冲突,或者是PHP,或者这里到底发生了什么,我希望有人能帮我弄清楚到底发生了什么 这就是我得到的。首先,这是我的HTML。这是我正在做的一个页面,它将“发布你的文本”到墙上(这是一个带有的)。以下是HTML正文: <div id="head"> <form name="postbar_add_post" id="postbar_add_post" method="post">
对进行分页。我不知道这是否是ID上的冲突,或者是PHP,或者这里到底发生了什么,我希望有人能帮我弄清楚到底发生了什么
这就是我得到的。首先,这是我的HTML。这是我正在做的一个页面,它将“发布你的文本”到墙上(这是一个带有
的)。以下是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>
//这是将输入中键入的内容发布到名为wall的div的脚本:
$.noConflict();
jQuery(文档).ready(函数(){
jQuery(“表单#postbar_add_post”).submit(函数(){
var addcontentbox=jQuery('#addcontentbox').attr('value');
if(addcontentbox.replace(/\s/g,“”=“”)返回false;
jQuery.ajax({
类型:“POST”,
url:“postear.php”,
数据:“addcontentbox=“+addcontentbox,
成功:函数(){
jQuery(“ul#wall”).prepend(“”+addcontentbox+” ”);
jQuery(“ul#wall li:first”).fadeIn();
document.postbar\u add\u post.addcontentbox.value='';
document.postbar\u add\u post.addcontentbox.focus();
}
});
返回false;
});
});
//这就是我尝试对内容进行分页的地方
$(文档).ready(函数(){
$(“#墙”).jPaginate();
});
因此,张贴工作非常好!但是分页从未发生,如果我更改函数以将其应用于父级
,则不会发生任何事情,它保持不变。在从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';
}
?>
任何类型的指导或解决方案都将不胜感激。我只是快速阅读了您的问题,我认为您使用了许多插件,所以我认为问题在于使用多个插件时,所以请始终使用如下自调用函数来包装您的javascript代码
(function($){
/// Your page code here
// Here you can use $
// We are passing jquery as $ to this self invoking function.
})(jQuery)