当前位置: 首页>>代码示例>>PHP>>正文


PHP AjaxResponse::error方法代码示例

本文整理汇总了PHP中AjaxResponse::error方法的典型用法代码示例。如果您正苦于以下问题:PHP AjaxResponse::error方法的具体用法?PHP AjaxResponse::error怎么用?PHP AjaxResponse::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AjaxResponse的用法示例。


在下文中一共展示了AjaxResponse::error方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionAjaxUpload

 /**
  * Action for uploading an image using AJAX.
  * @param string $name name for locating the uploaded file.
  * @param string $preset name of the preset.
  * @param string $saveName image name.
  * @param string $path image path.
  * @throws CException if the uploaded file is not found.
  */
 public function actionAjaxUpload($name, $preset = null, $saveName = null, $path = null)
 {
     $ajax = new AjaxResponse();
     $file = CUploadedFile::getInstanceByName($name);
     if ($file === null) {
         $ajax->error(sprintf('Uploaded file with name "%s" could not be found.', $name));
     }
     $manager = $this->getManager();
     try {
         $model = $manager->saveModel(new UploadedFile($file), $saveName, $path);
         $ajax->add('imageId', $model->id);
         if ($preset !== null) {
             $preset = $manager->loadPreset($preset);
             $ajax->add('imageTooSmall', $preset->getWidth() > $model->width || $preset->getHeight() > $model->height);
             $ajax->add('imageUrl', $manager->createImagePresetUrl($model, $preset));
         }
         $ajax->success();
     } catch (Exception $e) {
         Yii::log(sprintf('Image upload failed with error: %s', $e->getMessage()), CLogger::LEVEL_ERROR, 'ImageManager');
         $ajax->error(t('imageManager', 'Something went wrong when uploading the image, please try again.'));
     }
 }
开发者ID:crisu83,项目名称:yii-imagemanager,代码行数:30,代码来源:ImageController.php

示例2: AjaxResponse

    $dbDRule = API::DRule()->get(array('druleids' => get_request('druleid'), 'output' => API_OUTPUT_EXTEND, 'selectDChecks' => API_OUTPUT_EXTEND, 'editable' => true));
    if (empty($dbDRule)) {
        access_deny();
    }
}
$_REQUEST['go'] = get_request('go', 'none');
// ajax
if (isset($_REQUEST['output']) && $_REQUEST['output'] == 'ajax') {
    $ajaxResponse = new AjaxResponse();
    if (isset($_REQUEST['ajaxaction']) && $_REQUEST['ajaxaction'] == 'validate') {
        $ajaxData = get_request('ajaxdata', array());
        foreach ($ajaxData as $check) {
            switch ($check['field']) {
                case 'port':
                    if (!validate_port_list($check['value'])) {
                        $ajaxResponse->error(_('Incorrect port range.'));
                    }
                    break;
                case 'itemKey':
                    $itemKey = new CItemKey($check['value']);
                    if (!$itemKey->isValid()) {
                        $ajaxResponse->error(_s('Incorrect key: "%1$s".', $itemKey->getError()));
                    }
                    break;
            }
        }
    }
    $ajaxResponse->send();
    require_once dirname(__FILE__) . '/include/page_footer.php';
    exit;
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:31,代码来源:discoveryconf.php

示例3: array

    $dbDRule = API::DRule()->get(array('druleids' => get_request('druleid'), 'output' => array('name', 'proxy_hostid', 'iprange', 'delay', 'status'), 'selectDChecks' => array('type', 'key_', 'snmp_community', 'ports', 'snmpv3_securityname', 'snmpv3_securitylevel', 'snmpv3_authpassphrase', 'snmpv3_privpassphrase', 'uniq', 'snmpv3_authprotocol', 'snmpv3_privprotocol', 'snmpv3_contextname'), 'editable' => true));
    if (empty($dbDRule)) {
        access_deny();
    }
}
$_REQUEST['go'] = get_request('go', 'none');
// ajax
if (isset($_REQUEST['output']) && $_REQUEST['output'] == 'ajax') {
    $ajaxResponse = new AjaxResponse();
    if (isset($_REQUEST['ajaxaction']) && $_REQUEST['ajaxaction'] == 'validate') {
        $ajaxData = get_request('ajaxdata', array());
        foreach ($ajaxData as $check) {
            switch ($check['field']) {
                case 'port':
                    if (!validate_port_list($check['value'])) {
                        $ajaxResponse->error(_('Incorrect port range.'));
                    }
                    break;
                case 'itemKey':
                    $itemKey = new CItemKey($check['value']);
                    if (!$itemKey->isValid()) {
                        $ajaxResponse->error(_s('Invalid key "%1$s": %2$s.', $check['value'], $itemKey->getError()));
                    }
                    break;
            }
        }
    }
    $ajaxResponse->send();
    require_once dirname(__FILE__) . '/include/page_footer.php';
    exit;
}
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:discoveryconf.php


注:本文中的AjaxResponse::error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。