javascript - Loading ajax JSON failure -


the bellow scripts runs @ local host not work @ site. i'm testing simple json script in jquerymobile list format idea wrong??

thanks

html page click call ajax function:

<!doctype html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" />      <link rel="stylesheet" href="protected/jquery/jquery.mobile.structure-1.0.1.min.css" />     <link rel="stylesheet" href="protected/themes/green/red_theme.min.css" /> <script src="news_services/js/jquery.js"></script> <script src="news_services/js/jquery.mobile-1.0rc1.min.js"></script> <script type="text/javascript" src="protected/jsnm.js"> </script> </head> <body > <div data-role="page" id="home" >     <div data-role="header" >         <h1>json testing</h1>         <div data-role="controlgroup" data-type="horizontal"></div>     </div>     <div data-role="content">         <p> json testing</p>     </div>     <div data-role="footer">         <a href="#getall_json" onclick="jsn1()" data-role="button" data-inline="true" data-icon="info">call json</a>     </div> </div> <div data-role="page" id="getall_json">     <div data-role="header" data-position="fixed" >         <h1>json format</h1>         <div data-type="horizontal" >             <a href="#home" data-role="button"  data-inline="true" data-icon="home">home</a>         </div>     </div>     <div data-role="content">         <ul id="siteslist" data-role="listview" data-filter="true" data-split-icon="gear" >         </ul>     </div>     <div data-role="footer" data-position="fixed"></div> </div> <div id="detailspage" data-role="page" >     <div data-role="header">         <h1>info</h1>         <div data-type="horizontal" >             <a href="#home" data-role="button"  data-inline="true" data-icon="home">home</a>         </div>     </div>     <div data-role="content">         <div id="sitesdetail" >         </div>     </div> </div> </body> </html> 

call ajax here:

var areaid=0;  function jsn1(val) {    var url_category="http://gonorth.co.il/protected/indexjson.php?";  $.ajax({     url: url_category,     type: "get",     data: 'no='+val+"&area="+areaid,     datatype: "json",     cache: false,      error: function () {         alert('loading ajax failure');         } ,     onfailure: function () {         alert('ajax failure');     } ,      statuscode: {         404: function() {             alert("missing info");         }        },     success: function(result) {             $('#siteslist li').remove();         $.each(result.sites,function(index,dat){             $("#siteslist").append(                 '<li>'+                 '<img src="images/'+dat.coupon_img+'" width=80/>' +                 '<p >name: '+dat.coupon_name+'</p>'+                 '<p >info: '+dat.street+'</p>'+                 '<p >address:'+dat.coupon_tmp+'</p>'+                 '</li>'             );         });          $('#siteslist').listview('refresh');             } }); } 

php results:

<?php     $arr = array();         $arr[] =[                 "coupon_id" => '1',                 "coupon_img" => '1.jpg',                 "street" => 'long text',                  "coupon_tmp" => 'address',                  "coupon_name" => 'name'                 ]; echo '{"sites":'.json_encode($arr).'}'; ?> 

when visit link: http://gonorth.co.il/protected/indexjson.php, looks json being served through php parser web server. should web server's settings , find out how set in such way json files served content-type of application/json. current response comes down conten-type of text/html, because it's trying parsed php parser , parser chokes on syntax, or that, , server renders html error page.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -