本文整理汇总了PHP中AjaxResponse::success方法的典型用法代码示例。如果您正苦于以下问题:PHP AjaxResponse::success方法的具体用法?PHP AjaxResponse::success怎么用?PHP AjaxResponse::success使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AjaxResponse
的用法示例。
在下文中一共展示了AjaxResponse::success方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AjaxResponse
check_fields($fields);
/*
* Ajax
*/
if (isset($_REQUEST['output']) && $_REQUEST['output'] == 'ajax') {
$ajaxResponse = new AjaxResponse();
$ajaxData = get_request('ajaxdata', array());
if (isset($_REQUEST['ajaxaction']) && $_REQUEST['ajaxaction'] == 'test') {
$result = array('expressions' => array(), 'final' => true);
$testString = $ajaxData['testString'];
foreach ($ajaxData['expressions'] as $id => $expression) {
$match = GlobalRegExp::matchExpression($expression, $testString);
$result['expressions'][$id] = $match;
$result['final'] = $result['final'] && $match;
}
$ajaxResponse->success($result);
}
$ajaxResponse->send();
require_once dirname(__FILE__) . '/include/page_footer.php';
exit;
}
/*
* Permissions
*/
if (isset($_REQUEST['regexpid'])) {
$regExp = DBfetch(DBSelect('SELECT re.regexpid FROM regexps re WHERE re.regexpid=' . zbx_dbstr(get_request('regexpid'))));
if (empty($regExp)) {
access_deny();
}
}
if (isset($_REQUEST['go']) && !isset($_REQUEST['regexpid'])) {
示例2: 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.'));
}
}