2012-07-10 69 views
1

我有这个问题,我喜欢做的是,没有刷新。 我想要的是,当我搜索然后按回车,播放列表不应该刷新。jQuery.ajax方法获取数据,而无需刷新

我的网页的网址样本http://cocopop12.site11.com/v1.7/index.php

是我的jQuery脚本是否正确?我是否需要使用ajax,以便页面不会刷新?

$(function(){ 
$('input[name="searchsubmit"]').click(function(e) {   
    e.preventDefault(); 
    var qS = $('#qsearch').val(); 

    $.ajax({ 
     type:"GET", 
     url:"", 
     data: qS, 
     dataype: 'html', 
     success: function(data){ 
      $('input#qsearch').html(data); 
      return false; 
     } 
    }) 
}); 
}); 

按钮是

<div class="search"> 
<form id="quick-search" action="" method="get"> 
<p> 
<label for="qsearch">Search:</label> 
<input class="tbox" id="qsearch" type="text" name="q" value="Keywords" title="Start typing and hit ENTER" onblur="if(this.value=='') this.value='Keywords';" onfocus="if(this.value=='Keywords') this.value='';" /> 
<input class="btn" alt="Search" type="image" name="searchsubmit" title="Search" src="./css/search.gif" /> 
</p> 
</form> 
</div> 

感谢的时间。

+0

你试过'返回false;' – 2012-07-10 11:46:01

回答

3

尝试success而不是done(),你无法通过Ajax调用datadone()方法:

$.ajax({ 
     type:"GET", 
     url:"", 
     data: qS, 
     datatype: 'html', 
     success: function(data){ 
      $('input#qsearch').html(data); 
     } 
    }).done(function() { 
     alert('done') 
    }) 
+0

okie让我试试 – user1506189 2012-07-10 11:45:19

+0

语法错误在该行成功 – user1506189 2012-07-10 11:46:40

+1

使用'',''dataType后面:'html'也是一个错字 – 2012-07-10 11:48:18