Changeset 23248


Ignore:
Timestamp:
2013/10/22 20:46:51 (8 years ago)
Author:
pineray
Message:

#2440 APIの情報をJSONPで取得できるようにする

Location:
branches/version-2_13-dev/data/class
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/data/class/api/SC_Api_Utils.php

    r23124 r23248  
    193193    public function sendResponseJson($response_outer_name, &$arrResponse) 
    194194    { 
    195         header('Content-Type: application/json; charset=UTF-8'); 
    196         $arrResponse['response_name'] = $response_outer_name; 
    197         echo SC_Utils_Ex::jsonEncode($arrResponse); 
     195        if (isset($arrResponse["callback"])) { 
     196            $callback = $arrResponse["callback"]; 
     197            unset($arrResponse["callback"]); 
     198            header('Content-Type: application/javascript; charset=UTF-8'); 
     199            $arrResponse['response_name'] = $response_outer_name; 
     200            echo $callback . "(" . SC_Utils_Ex::jsonEncode($arrResponse) . ")"; 
     201        } else { 
     202            header('Content-Type: application/json; charset=UTF-8'); 
     203            $arrResponse['response_name'] = $response_outer_name; 
     204            echo SC_Utils_Ex::jsonEncode($arrResponse); 
     205        } 
    198206    } 
    199207 
  • branches/version-2_13-dev/data/class/pages/api/LC_Page_Api_Json.php

    r23124 r23248  
    6565 
    6666        list($response_outer, $arrResponse) = SC_Api_Operation::doApiAction($arrParam); 
     67 
     68        if (isset($arrParam["callback"])) { 
     69            $arrResponse["callback"] = $arrParam["callback"]; 
     70        } 
     71 
    6772        SC_Api_Operation_Ex::sendApiResponse('json', $response_outer, $arrResponse); 
    6873        SC_Response_Ex::actionExit(); 
Note: See TracChangeset for help on using the changeset viewer.