Membuat Tombol Loadmore Pada Google Seach Engine


Mari kita perhatikan contoh kode Jquery ini :

<p id="result"></p>
<p id="result2" style="display:none"></p>
<p id="result3"></p>
<p id="btnload"></p>

<script>
var ttle1='php';
var ttle=decodeURIComponent(ttle1);
$( document ).ready(function() {
GetResult(ttle,'result','2','result2','btnload');
});
</script>


<script>
function GetResult(keywords,divouts,banyak,divoutl,divoutr)
{
var keys = 'YourGoogleKey';
var url='https://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=8&start=0&key='+keys+'&q=site:blogspot.com+'+keywords;
$.ajax({
type: "GET",
url: url+'&callback=?',
dataType: 'json',
error: function(){
       alert('Unable to load feed, Incorrect path or invalid feed');
       },
success: function(data){
         $.each(data.responseData.results, function(i,data){
         $("#"+divouts).append('<a href="javascript:void(0)" onclick="GoToPage(\''+data.visibleUrl+'\')">'+data.title+'</a><br/>'+data.content+'<br/><a href="javascript:void(0)" onclick="GoToPage(\''+data.visibleUrl+'\')">https://www-global-info.blogspot.com/'+data.title+'</a><br/><br/>');
       return i<banyak;
         });
         $("#"+divoutl).append(banyak);
         $("#"+divoutr).append('<button onclick="loadMore(\''+keywords+'\',\''+divoutl+'\',\''+banyak+'\')">LOAD MORE</button>');
       }
});
}

function loadMore(qword,divs,limited) 
{
var jml = parseInt($("#"+divs).text())+1;
$("#"+divs).html(jml);
var keys = 'YourGoogleKey';
var url='https://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=8&start='+jml+'&key='+keys+'&q=site:blogspot.com+'+qword;
$.ajax({
type: "GET",
url: url+'&callback=?',
dataType: 'json',
error: function(){
       alert('Unable to load feed, Incorrect path or invalid feed');
       },
success: function(data){
         $.each(data.responseData.results, function(i,data){
         $("#result3").append('<a href="javascript:void(0)" onclick="GoToPage(\''+data.visibleUrl+'\')">'+data.title+'</a><br/>'+data.content+'<br/><a href="javascript:void(0)" onclick="GoToPage(\''+data.visibleUrl+'\')">https://www-global-info.blogspot.com/'+data.title+'</a><br/><br/>');
       return i<limited;
         });
       }
});
}
</script>


Smoga bisa menjadi inspirasi....
Previous
Next Post »