我有這個問題,我喜歡做的是,沒有刷新。 我想要的是,當我搜索然後按回車,播放列表不應該刷新。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>
感謝的時間。
你試過'返回false;' – 2012-07-10 11:46:01