aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV.Krishn <vkrishn4@gmail.com>2016-07-02 00:53:53 +0530
committerV.Krishn <vkrishn4@gmail.com>2016-07-02 00:53:53 +0530
commit386d5b8fc58212efa899b4c6adc6ebbd98d85a02 (patch)
tree18c951f327b1c4147c9d290a873da2acd27bd8df
parent1a0b83e9dc6ffd6c1652b3683c39d1cd0eb39bd0 (diff)
downloadaport-api-386d5b8fc58212efa899b4c6adc6ebbd98d85a02.tar.bz2
check jquery jsonp request
-rw-r--r--index.php10
1 files changed, 9 insertions, 1 deletions
diff --git a/index.php b/index.php
index b2ac826..be15116 100644
--- a/index.php
+++ b/index.php
@@ -1102,7 +1102,15 @@ function json_api_encode($data, $app, $flags=array()) {
//enable in production
$app->response->setContentType($header['japi'])->sendHeaders();
$data = get_meta_end($data, $app);
- echo json_encode($data);
+
+ //JSONP
+ if(isset($_GET['aportsjsonp']) || isset($_GET['callback'])) {
+ $callback = $_GET['aportsjsonp'] ? 'aportsjsonp' : $_GET['callback'];
+ echo $callback.'(' . json_encode($data) . ')';
+ } else {
+ echo json_encode($data);
+ }
+
}
// --------------------------