我在 keyup 事件上向页面本身发送参数。
我通过 ajax 发送参数url:"http://localhost/application/views/pages/users/tags.php?tagfilter=lif",
并在 javascript 函数中获取它的值('/instruction/showtags/<?php if( isset($_GET['tagfilter']) && $_GET['tagfilter'] == "") {echo $_GET['tagfilter'];} ?> ', {
我检查了,我的控制台,它没有显示错误和警告。但我确信它要么没有发送参数,要么可能是它没有获取参数。
请告诉我,为什么我的参数没有发送?ajax代码的编写方式是否正确?
如果您无法理解我的问题,请告诉我,我会尝试以其他方式解释。
完整源代码:
标签.php
<input placeholder="Search" id="tagfilter" name="tagfilter" type="text"/>
jQuery/ajax 函数
<script type="text/javascript">
$(document).ready(function() {
$('#tagfilter').keyup(function(e){
// alert("called");
$.ajax({
url:"http://localhost/application/views/pages/users/tags.php?
tagfilter=lif",
type:"get",
success: function(){
}
});
});
});
</script>
我的无限滚动 js 文件,包括在同一页面中
<script>
(function($) {
$.fn.scrollPagination = function(options) {
var settings = {
nop : 10, // The number of posts per scroll to be loaded
offset : 0, // Initial offset, begins at 0 in this case
error : 'No More Data To Display!', // When the user reaches the end this is the message that is
// displayed. You can change this if you want.
delay : 500, // When you scroll down the posts will load after a delayed amount of time.
// This is mainly for usability concerns. You can alter this as you see fit
scroll : true // The main bit, if set to false posts will not load as the user scrolls.
// but will still load if the user clicks.
}
.............................
.............................
.............................
更新:
我到底想做什么?
我已经用 jquery 实现了无限滚动。当我的页面加载时,它会调用我的控制器,并从控制器获取数据并将其显示在我的视图页面中。
现在,我打算在这个页面上无限滚动搜索。我有一个文本框,我试图从这个文本框中搜索 keyup 事件。
我正在尝试这个逻辑。如果您有更好的逻辑,请与我分享,因为我长期以来一直在努力实现这一点。