var vURL = "http://webs.academia.cat/assets/api_cicle/api/apinoticies.php"; $.ajax({ url: vURL, type: "POST", data: { codient: '039', tipusent: '2', paginacio: "false", format:'json', limit: '2', nomcat: '7', autoIni: 'true', random: 'true', detall: '?p=page/html/detalldestacats', param_idnoticia : '/' }, success: function (r) { /* Exemple*/ //$("#retornHTMLNoticies").html(r[0]['TITOL']); var num_noti = Object.keys(r).length; //alert(Object.keys(r).length); if (num_noti>0) { var data = r; $.each( data, function( key, val ) { var i= eval(parseInt(key) +1); $("#titol_destacat_"+i).html(val['TITOL']); $("#extracte_destacat_"+i).html(val['COS']); }); molins_destacat(); } } });