2012-07-10 34 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