當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Ajax::run方法代碼示例

本文整理匯總了PHP中Ajax::run方法的典型用法代碼示例。如果您正苦於以下問題:PHP Ajax::run方法的具體用法?PHP Ajax::run怎麽用?PHP Ajax::run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Ajax的用法示例。


在下文中一共展示了Ajax::run方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: function

Ajax::run('getRelations', 'both', function () {
    $current_user = wp_get_current_user();
    $ret = [];
    // need to get the evaluations a user is associated with
    // in order to get the corresponding unique relations
    $unique_relation_ids = [];
    if (0 !== $current_user->ID) {
        $evaluations = null;
        if ('administrator' === $current_user->roles[0]) {
            $evaluations = get_posts(['post_type' => 'evaluation', 'posts_per_page' => -1]);
        } else {
            $evaluations = UserModel::getRelations($current_user->ID);
        }
        foreach ($evaluations as $key => $evaluation) {
            $evaluation_pod = pods('evaluation', (int) $evaluation->ID);
            $relation = $evaluation_pod->field('relation');
            if (!$relation) {
                continue;
            }
            if (!in_array($relation['ID'], $unique_relation_ids)) {
                $relation_pod = pods('relation', $relation['ID']);
                if (!$relation_pod) {
                    continue;
                }
                $ret[] = ['company' => $relation_pod->field('company'), 'agency' => $relation_pod->field('agency'), 'brand' => $relation_pod->field('brand'), 'country' => $relation_pod->field('country'), 'period_year' => $relation_pod->field('period_year'), 'period_quarter' => $relation_pod->field('period_quarter'), '180_360' => $evaluation_pod->field('180_360'), 'post' => $relation];
                $unique_relation_ids[] = $relation['ID'];
            }
        }
    }
    // response output
    header("Content-Type: application/json");
    echo json_encode($ret);
    exit;
});
開發者ID:strikles,項目名稱:php,代碼行數:34,代碼來源:reporting.php

示例2: json_decode

    $filename = $type . '_' . $limesurvey_id . '_questions.json';
    $questions = json_decode(file_get_contents(CABSPATH . 'cache/' . $filename), true);
    $user_role = $_POST['userRole'];
    // response output
    header("Content-Type: application/json");
    echo json_encode($questions[$user_role]);
    exit;
});
/**
 *
 */
Ajax::run('genRelationSurveys', 'both', function () {
    $evaluation_id = $_REQUEST['evaluation_id'];
    $evaluation_pod = pods('evaluation', $evaluation_id);
    $relation = $evaluation_pod->field('relation');
    $relation_pod = pods('relation', $relation['ID']);
    $relation_type = $evaluation_pod->field('180_360');
    $relation_steps = EvaluationModel::getSteps($relation_type);
    $survey_ids = [];
    foreach ($relation_steps as $key => $curr_step) {
        $questions_type = $curr_step === '360' ? 'company' : 'agency';
        $limesurvey_id = EvaluationModel::surveyID($evaluation_id, $curr_step);
        $survey_ids[] = $limesurvey_id;
        $groups = LimesurveyModel::generateGroupsJsonCache($limesurvey_id, $questions_type);
        LimesurveyModel::generateQuestionsJsonCache($limesurvey_id, $questions_type, $groups);
    }
    // response output
    header("Content-Type: application/json");
    echo json_encode($survey_ids);
    exit;
});
開發者ID:strikles,項目名稱:php,代碼行數:31,代碼來源:limesurvey.php


注:本文中的Ajax::run方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。