修改了相关搜索的json数据加载方式

This commit is contained in:
Li Jianxuan 2012-04-16 05:51:51 +00:00
parent 46bbfe88a7
commit f71146bf2f
1 changed files with 12 additions and 8 deletions

View File

@ -546,9 +546,8 @@ $('.scholar').click(function(){scholarSearch('<?php echo $ev;?>');});
function googleSearch(keyword){
$.ajax({type:"POST",url:"/service/googlesearch",data:'q='+keyword,
success:function(html){
success:function(obj){
var items = [];
var obj = jQuery.parseJSON(html);
$.each(obj.responseData.results, function(key, val) {
var html = '<p><a href="' +val['unescapedUrl']+'">'+val['title']+'<a/></p><p><span>'
+val['url'].replace(/%(.*)/i,"") +'</span></p><p>'
@ -560,16 +559,17 @@ function googleSearch(keyword){
$('#searchlist').html(items.join(''));
$('html, body').animate({scrollTop:$('#searchlist').offset().top}, 'slow');
},
dataType:"json",
error:function(){alert("处理中发生错误,请刷新页面后重试");},
beforeSend:function(){$('#searchlist').html('<img src="/images/loading.gif" />结果加载中');}
});
}
function scholarSearch(keyword){
$.ajax({type:"POST",url:"/service/scholarsearch",data:'q='+keyword,
success:function(html){
success:function(obj){
//$('#searchlist').html(html);return false;
var items = [];
var obj = jQuery.parseJSON(html);
if(obj.error != '')
{
items.push('<li>' + obj.error + '</li>');
@ -586,15 +586,16 @@ function scholarSearch(keyword){
$('#searchlist').html(items.join(''));
$('html, body').animate({scrollTop:$('#searchlist').offset().top}, 'slow');
},
dataType:"json",
error:function(){alert("处理中发生错误,请刷新页面后重试");},
beforeSend:function(){$('#searchlist').html('<img src="/images/loading.gif" />结果加载中');}
});
}
function bingSearch(keyword){
$.ajax({type:"POST",url:"/service/bingsearch",data:'q='+keyword,
success:function(html){
success:function(obj){
var items = [];
var obj = jQuery.parseJSON(html);
$.each(obj.SearchResponse.Web.Results, function(key, val) {
var html = '<p><a href="' +val['Url']+'">'+val['Title']+'<a/></p><p><span>'
+val['DisplayUrl'].replace(/%(.*)/i,"") +'</span></p><p>'
@ -606,15 +607,16 @@ function bingSearch(keyword){
$('#searchlist').html(items.join(''));
$('html, body').animate({scrollTop:$('#searchlist').offset().top}, 'slow');
},
dataType:"json",
error:function(){alert("处理中发生错误,请刷新页面后重试");},
beforeSend:function(){$('#searchlist').html('<img src="/images/loading.gif" />结果加载中');}
});
}
function cnkiSearch(keyword){
$.ajax({type:"POST",url:"/service/cnkisearch",data:'q='+keyword,
success:function(html){
success:function(obj){
var items = [];
var obj = jQuery.parseJSON(html);
if(obj.error != '')
{
items.push('<li>' + obj.error + '</li>');
@ -632,6 +634,8 @@ function cnkiSearch(keyword){
$('#searchlist').html(items.join(''));
$('html, body').animate({scrollTop:$('#searchlist').offset().top}, 'slow');
},
dataType:"json",
error:function(){alert("处理中发生错误,请刷新页面后重试");},
beforeSend:function(){$('#searchlist').html('<img src="/images/loading.gif" />结果加载中');}
});
}