php - getJson not working on webhosting -
i have slight problem. connecting web service provides json results , trying parse results. code working fine on localhost (wamp server) code doesn't run on of web hosting accounts tried. here url providing json
http://mohamedbadr.com/webservice/list.php
and here file trying fetch results:
http://contestlancer.com/web/getlist.php
here code of getlist file:
<!doctype html> <html> <head> <title>hotel promotion list</title> <script type="text/javascript" src="jquery.js"></script> <link rel="stylesheet" type="text/css" href="style.css"/> <script type="text/javascript"> function getlist() { var i=0; var ntable="<table><thead><tr><th>image</th><th>name</th><th>rating</th><th>highlights</th></tr></thead><tbody>"; $.getjson("http://mohamedbadr.com/webservice/list.php", function(data){ $.each(data.promos, function(key, value) { ntable+="<tr><td><a href='promotion.php?id="+value.promo.id+"'><img src='"+value.promo.image+"' height='100' width='150'/></a></td><td><a href='promotion.php?id="+value.promo.id+"'>"+value.promo.name+"</a></td><td> "+value.promo.stars+"</td><td> "+value.promo.highlights+"</td></tr>"; }); ntable+="</tbody></table>"; $("#content").html(ntable); }); } </script> </head> <body onload="getlist()"> <div id="wrapper"> <div id="content"></div> </div> </body> </html>
most url not being opened solution this? highly appreciated
it's not working because making cross domain request. domain domain b.
try adding http://mohamedbadr.com/webservice/list.php
before output printed.
header('access-control-allow-origin: http://contestlancer.com');
Comments
Post a Comment