the bellow scripts runs at my Local Host but does not work at my Site. I'm just testing simple Json script in jqueryMobile list format any idea what is wrong??
thanks
HTML page click to 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).'}';
?>