【发布时间】:2013-05-15 19:48:30
【问题描述】:
我在 keyup 事件上向页面本身发送参数。
我通过像url:"http://localhost/application/views/pages/users/tags.php?tagfilter=lif",这样的ajax发送一个参数
并在 javascript 函数中获取其值 ('/instruction/showtags/<?php if( isset($_GET['tagfilter']) && $_GET['tagfilter'] == "") {echo $_GET['tagfilter'];} ?> ', {
我检查了我的控制台,它没有显示错误和警告。 但我确信它要么没有发送参数,要么可能没有获取参数。
请告诉我,为什么我的参数没有发送? ajax代码的写法是否正确?
如果你不能理解我的问题,请告诉我,我会尝试用其他方式解释。
完整源代码:
tags.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 事件。
我正在尝试这种逻辑。如果您有更好的逻辑,请与我分享,因为我长期以来一直在努力实现这一点。
【问题讨论】:
-
在你的代码顶部,不应该是
$_GET['tagfilter'] != ""吗? (注!=) -
@JerrySeeger 我听不懂你的话。请以其他方式告诉它。谢谢
-
只是好奇:您是否对your other account 提出您自己的问题?
-
if( isset($_GET['tagfilter']) && $_GET['tagfilter'] == "")应该是if( isset($_GET['tagfilter']) && $_GET['tagfilter'] != "") -
当您可以使用分段时,为什么要在 Ci 中发送
$_GET。我认为您在实施您的想法时遇到了问题。请详细描述您的想法,以便我们提供更多帮助
标签: php javascript jquery ajax codeigniter