function JSON_Result($s_result, $a_data = array())
{
    $a_data["Result"] = $s_result;
    $json = new JSON();
    echo $json->MakeObject($a_data);
}
예제 #2
0
function JSON_Result($s_result, $a_data = array())
{
    global $aGetVars;
    FMDebug("Sending JSON_Result: {$s_result}");
    $a_data["Result"] = $s_result;
    $json = new JSON();
    $s_ret = $json->MakeObject($a_data);
    CORS_Response();
    //
    // handle JSONP request
    //
    if (isset($aGetVars['callback']) && $aGetVars['callback'] != '') {
        header('Content-Type: text/javascript; charset=utf-8');
        $s_ret = $aGetVars['callback'] . "({$s_ret});";
        FMDebug('JSONP request callback=' . $aGetVars['callback']);
    } else {
        header('Content-Encoding: utf-8');
        header('Content-Type: application/json; charset=utf-8');
    }
    FMDebug("JSON_Result output: " . $s_ret);
    echo $s_ret;
}