php - json is not retrieving data -
php - json is not retrieving data -
i'm new json , i'm having problems retrieving info think cross domain issue can't work.
php files:
include ('tew.php'); $converter = new encryption; $query="select tbl_pizarra.idpizarra, tbl_pizarra.titulo, tbl_pizarra.imagenchica tbl_pizarra order idpizarra desc limit 3"; $sql=mysqli_query($tew,$query); $datosjson = '{"pizarra": ['; while($row=mysqli_fetch_array($sql)) { $datosjson .= '{ "idpizarra":"'.$converter->encode($row['idpizarra']).'", "titulo":"'.$row['titulo'].'", "imagenchica":"'.$rutaimagenes.$row['imagenchica'].'" },'; } $datosjson .= ']}'; echo $datosjson; include ('tew.php'); $converter = new encryption; $query="select tbl_pizarron.idpizarron, tbl_pizarron.titulo, tbl_pizarron.imagen tbl_pizarron order idpizarron desc limit 3"; $sql=mysqli_query($tew,$query); $datosjson = '{"pizarron": ['; while($row=mysqli_fetch_array($sql)) { $datosjson .= '{ "idpizarron":"'.$converter->encode($row['idpizarron']).'", "titpizarron":"'.utf8_encode($row['titulo']).'" },'; } $datosjson .= ']}'; echo $datosjson;
json data:
{"pizarra": [{ "idpizarra":"xet8dkak_f-4rluq7bryppgv3lvuc7prbpm722fjqpu", "titulo":"bienvenida y agradecimiento casa 22", "imagenchica":"http://tuedificiowebdemo.com/images/pizarras/tew_caminadora suspiro 21386344709.jpg" },{ "idpizarra":"nkblz3he-abmnfbqninkn89mx6nwvar-yfqeunjywbm", "titulo":"proyecto plantas", "imagenchica":"http://tuedificiowebdemo.com/images/pizarras/tew_foto1380142984.jpg" },{ "idpizarra":"zakioe6yavb8q0ybnn13b-wdi9fygoriivmwumy7ldu", "titulo":"compra de la cubierta de la alberca", "imagenchica":"http://tuedificiowebdemo.com/images/pizarras/tew_cubiertadealberca21378356769.jpg" },]} {"pizarron": [{ "idpizarron":"i0jks9amm3znh1mg__od5sd_budp5h8zbisrpqkqj3o", "titpizarron":"fechas cortes jardines" },{ "idpizarron":"dfa-lpljkejwagsdmy5bjes3y6drqn0eoxd568mywy8", "titpizarron":"cuota de mantenimiento 2014" },{ "idpizarron":"yce4ymz2ridnmkyr5y1du2tmtni7etda2667f_5neyq", "titpizarron":"proximas fechas de corte jardines" },]}
html file im using informaiton:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script> <script type="text/javascript"> $(function() { $(document).ready(function() { $.getjson("http://tuedificiowebdemo.com/tewmobile/php/noticiaspizarra2.php?jsoncallback=?",function(data) { $.each(data.pizarra, function(i,data) { var div_data = "<a href='documentos_detalles.html?id="+data.idpizarra+"' class='noticlick'><div><img src='images/alert.png' width=100' align='absmiddle'>"+" "+data.titulo+"</div></a>"; $(div_data).appendto("#pizarra"); }); } ); $.getjson("http://tuedificiowebdemo.com/tewmobile/php/noticiaspizarron2.php?jsoncallback=?",function(data) { $.each(data.pizarron, function(i,data) { var div_data = "<a href='documentos_detalles.html?id="+data.idpizarron+"' class='noticlick'><div>"+data.titpizarron+"</div></a>"; $(div_data).appendto("#pizarron"); }); } ); homecoming false; }); }); </script> <div id="pizarra"></div> <div id="pizarron"></div>
any sugestion.... thanks.
create array in php , utilize json_encode $json = json_encode($array) create string json data. you outputting 2 independent json strings not read correctly. both getjson same double invalid json string.
invalid example:
{/*data here*/} {/*data here*/}
valid:
[ {/*data here*/}, {/*data here*/} ]
php jquery html json
Comments
Post a Comment