heihe view中cnki搜索添加了无返回结果的判断
This commit is contained in:
parent
66da794226
commit
9df01d3cbe
|
@ -953,6 +953,8 @@ class ServiceController extends Zend_Controller_Action
|
|||
foreach ($matchs[1] as $k=>$v){
|
||||
if($k < $max) $rev[$k]['url']=$v;
|
||||
}
|
||||
}else{
|
||||
$error = "无搜索结果";
|
||||
}
|
||||
|
||||
if(preg_match_all("#<span class=\"search_result_snap\" >(.+?)</span>#i",$body,$matchs,PREG_PATTERN_ORDER))
|
||||
|
@ -962,7 +964,7 @@ class ServiceController extends Zend_Controller_Action
|
|||
}
|
||||
}
|
||||
|
||||
$response=array("result"=>$rev,"count"=>$max,"morelink"=>'http://search.cnki.net/search.aspx?q='.$keyword);
|
||||
$response=array("result"=>$rev,"count"=>$max,"morelink"=>'http://search.cnki.net/search.aspx?q='.$keyword,"error"=>$error);
|
||||
|
||||
$rev = Zend_Json::encode($response);
|
||||
return $rev;
|
||||
|
|
|
@ -480,14 +480,20 @@ function cnkiSearch(keyword){
|
|||
success:function(html){
|
||||
var items = [];
|
||||
var obj = jQuery.parseJSON(html);
|
||||
$.each(obj.result, function(key, val) {
|
||||
var html = '<p><a href="' +val['url']+'" target="_blank">'+val['title']+'<a/></p><p><span>'
|
||||
+val['url'].replace(/%(.*)/i,"") +'</span></p><p>'
|
||||
+val['content']
|
||||
+'</p>';
|
||||
alert(obj.error);
|
||||
if(obj.error != '')
|
||||
{
|
||||
items.push('<li>' + obj.error + '</li>');
|
||||
}else{
|
||||
$.each(obj.result, function(key, val) {
|
||||
var html = '<p><a href="' +val['url']+'" target="_blank">'+val['title']+'<a/></p><p><span>'
|
||||
+val['url'].replace(/%(.*)/i,"") +'</span></p><p>'
|
||||
+val['content']
|
||||
+'</p>';
|
||||
|
||||
items.push('<li>' + html + '</li>');
|
||||
});
|
||||
items.push('<li>' + html + '</li>');
|
||||
});
|
||||
}
|
||||
items.push('<li class="more"><a href="'+obj.morelink+'" target="_blank">查看更多搜索结果</a></div>');
|
||||
$('#searchlist').html(items.join(''));
|
||||
$('html, body').animate({scrollTop:$('html').height()}, 'slow');
|
||||
|
|
Loading…
Reference in New Issue