【发布时间】:2010-09-30 06:25:29
【问题描述】:
我需要你的一点帮助。
在我的情况下,我在 b.php 上有搜索文本框,用户可以在其中输入用户名并按 Enter 以获取搜索的用户详细信息。 好的,到目前为止。现在我处理数据库的搜索代码已经在 c.php 中准备好了,我想通过 b.php 和 jquery 的事件来调用它。 实际上,我的 a.php 是主文件,并在单击事件时通过它调用 b.php。现在 jquery 的流程将是这样的 a.php > b.php > c.php
没有搜索按钮,按回车键只会给搜索到的用户。
我在 jquery 中将我的代码写为:
$(document).ready(function(){
$('#srchtxt').bind('click', function(){
if($('#srchtxt').val() != '') {
$('#loading').html('<img src="images/ajax-loader(1).gif">');
$('#loading').show();
$.get('/usersearch.php?tnm3='+arr3, '', function(data){
$('#content').html(data);
$('#loading').hide();
});
}
});
$('#srchtxt').bind('keyup', function(e){
if(e.keyCode==13) {
$("#srchtxt").trigger('click');
}
});
});
此活动无效。你能帮帮我吗?
【问题讨论】:
-
什么是
'#srchtxt'?在simple test case 中展示了这个作品。 -
@Reigel 是文本框的 id。
-
看看我的测试用例,你的代码有效。
-
#srchtxt是否响应click事件?