Commit 6ec1789f authored by arlo gn's avatar arlo gn

Cross-domain communication with JSONP

Enable cors for all domains isn't a good practice. Maybe in this case is better use jsonp. I added a new param to get response with this method.
parent 81b4a577
......@@ -51,7 +51,11 @@ elseif ($_GET['format'] == "json") {
$rows=array_values(pg_fetch_all($result));
$obj->podcount = $numrows;
$obj->pods = $rows;
print json_encode($obj);
if ($_GET['method'] == "jsonp") {
print $_GET['callback'] . '(' . json_encode($obj) . ')';
} else {
print json_encode($obj);
}
} else {
$i=0;
$sql = "SELECT * FROM pods WHERE hidden <> 'yes' ORDER BY uptimelast7 DESC";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment