Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

API - limit output with variable

0 votes
9 views
added Jun 19 in API by LC Marshal Lieutenant (14,930 points)
edited Jul 13 by LC Marshal
//comma plugin
$.fn.digits = function(){ 
    return this.each(function(){ 
        $(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") ); 
    })
}

var getProjname = $('.project-detail ul li:first-child .i-list-data').text(), 
    outlookPLislnk = 'https://alice.edgeprop.my/property/v1/nsearch?&keyword=', //API
    intypeSale = '&listing_type=sale',
    recOutput = '&size=4&order_by=posted_desc', //limit with size
    recTotalOutput = outlookPLislnk + getProjname + recOutput;

//recommendation listings
$.getJSON(recTotalOutput, function(recommendedList) {
var property_data = '';
$.each(recommendedList.property, function(index, row) {
  var listPrice = row.field_prop_asking_price.und["0"].value;
  property_data += '<div class="col-md-3 opacity-hover">';
  property_data += '<a target="_blank" href="'+'/listing/'+row.url+'"><span><img src="'+row.field_prop_images+'"></span></a>';
  property_data += '<span class="single-card"><span class="title"><a target="_blank" href="'+'/listing/'+row.url+'">'+row.title+'</a></span>';   
  property_data += '<span class="meta">'+row.district+', '+row.state+'</span>';
  property_data += '<span class="price-listing">RM '+listPrice+'</span></span>';
  property_data += '</div>';
});

var outlookListing    = $('#outlook-property-listing .row').append(property_data),
    outlooklistingWrp = $('#outlook-listing-wrapper');

$('.content-bottom.p-t-50.p-b-50').before('<div class="container showlisting"></div>');
$('.container.showlisting').append(outlooklistingWrp);
$('#outlook-property-listing').fadeIn(300);
$('.price-listing').digits(); //comma plugin
});

Please log in or register to response this reference.

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...