diff options
author | V.Krishn <vkrishn4@gmail.com> | 2016-07-02 00:53:53 +0530 |
---|---|---|
committer | V.Krishn <vkrishn4@gmail.com> | 2016-07-02 00:53:53 +0530 |
commit | 386d5b8fc58212efa899b4c6adc6ebbd98d85a02 (patch) | |
tree | 18c951f327b1c4147c9d290a873da2acd27bd8df | |
parent | 1a0b83e9dc6ffd6c1652b3683c39d1cd0eb39bd0 (diff) | |
download | aport-api-386d5b8fc58212efa899b4c6adc6ebbd98d85a02.tar.bz2 |
check jquery jsonp request
-rw-r--r-- | index.php | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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); + } + } // -------------------------- |