本文整理汇总了PHP中request::ajax方法的典型用法代码示例。如果您正苦于以下问题:PHP request::ajax方法的具体用法?PHP request::ajax怎么用?PHP request::ajax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类request
的用法示例。
在下文中一共展示了request::ajax方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: splash
/**
* @brief 错误或者成功输出
*
* @param string $status
* @param stirng $url
* @param string $msg
* @param string $method
* @param array $params
*
* @return string
*/
public function splash($status = 'success', $url = null, $msg = null, $ajax = true)
{
$status = $status == 'failed' ? 'error' : $status;
//如果需要返回则ajax
if ($ajax == true || request::ajax()) {
return response::json(array($status => true, 'message' => $msg, 'redirect' => $url));
}
if ($url && !$msg) {
//如果有url地址但是没有信息输出则直接跳转
return redirect::to($url);
}
}
示例2: handle
public function handle($request, Clousure $next)
{
$routeAs = route::currentRouteName();
$currentPermission = shopAuth::getSellerPermission();
//$currentPermission = false 表示为店主不用判断权限
//获取当前用户的路由权限
if ($currentPermission && !in_array($routeAs, $currentPermission)) {
if (request::ajax()) {
return response::json(array('error' => true, 'message' => '无操作权限'));
} else {
return redirect::action('topshop_ctl_index@nopermission');
}
}
return $next($request);
}
示例3: splash
public function splash($status = 'success', $url = null, $msg = null, $ajax = false)
{
$status = $status == 'failed' ? 'error' : $status;
//如果需要返回则ajax
if ($ajax == true || request::ajax()) {
return response::json(array($status => true, 'message' => $msg, 'redirect' => $url));
}
if ($url && !$msg) {
//如果有url地址但是没有信息输出则直接跳转
return redirect::action($url);
}
$this->setLayoutFlag('splash');
$pagedata['msg'] = $msg;
return $this->page('topm/splash/error.html', $pagedata);
}
示例4: location_to
function location_to()
{
//echo request::url(). '#'.$_SERVER['QUERY_STRING'];
if (request::ajax() != true) {
header('Location: ' . request::url() . '#' . $_SERVER['QUERY_STRING']);
}
}
示例5: ajax
protected function ajax()
{
return request::ajax() || request::wantsJson();
}
示例6: create
public function create(request $request)
{
if ($request->ajax()) {
}
}
示例7: main
function main()
{
if (isset($this->detail_pages)) {
foreach ((array) $this->detail_pages as $k => $detail_func) {
$str_detail_order = 'detail_' . $detail_func[1] . '_order';
if (isset($detail_func[0]->{$str_detail_order}) && $detail_func[0]->{$str_detail_order}) {
switch ($detail_func[0]->{$str_detail_order}) {
case COLUMN_IN_HEAD:
$tmp = $this->detail_pages[$k];
unset($this->detail_pages[$k]);
$this->detail_pages = array_reverse($this->detail_pages);
$this->detail_pages[$k] = $tmp;
$this->detail_pages = array_reverse($this->detail_pages);
break;
case COLUMN_IN_TAIL:
$tmp = $this->detail_pages[$k];
unset($this->detail_pages[$k]);
$this->detail_pages[$k] = $tmp;
break;
}
}
}
}
if (request::ajax() && $_GET['singlepage'] != 'true') {
//$_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
if (isset($this->detail_pages)) {
$tab_header = '<div class="tabs-wrap finder-tabs-wrap"><div class="tabs-items clearfix"><ul>';
foreach ($this->detail_pages as $k => $detail_func) {
if ($k == $_GET['finderview']) {
$tab_header .= '<li class="tab current" item-id="' . $_GET['id'] . '" url="' . $this->url . '&action=detail&finderview=' . $k . '"><span>';
$tab_header .= $detail_func[0]->{$detail_func}[1];
$detail_html = $detail_func[0]->{$detail_func}[1]($_GET['id']);
} else {
//if($_GET['view'])unset($_GET['view']);
$tab_action = $this->url . '&action=detail&finderview=' . $k;
$tab_header .= '<li class="tab"><span>';
$tab_header .= '<a target="{update:\'finder-detail-' . $this->name . '\'}" href="' . $tab_action . '">' . $detail_func[0]->{$detail_func}[1] . '</a>';
}
$tab_header .= '</span></li>';
}
$tab_header .= '</ul></div>' . '<div class="scroll-handle l"><span>«</span></div>' . '<div class="scroll-handle r"><span>»</span></div></div>';
}
$output = '';
if (count($this->detail_pages) > 1) {
$output = $tab_header;
}
return $output . $detail_html;
} else {
if (request::ajax() && $_GET['singlepage'] == 'true') {
foreach ($this->detail_pages as $k => $detail_func) {
if ($_GET['finderview'] == $k) {
$html = $detail_func[0]->{$detail_func}[1]($_GET['id']);
$label = $detail_func[0]->{$detail_func}[1];
echo <<<EOF
<h3>{$label}</h3>
{$html}
EOF;
exit;
}
}
} else {
foreach ($this->detail_pages as $k => $detail_func) {
$detail_html = $detail_func[0]->{$detail_func}[1]($_GET['id']);
$pagedata['_detail_func'][$k] = array('label' => $detail_func[0]->{$detail_func}[1], 'html' => $detail_html);
}
return $this->controller->singlepage('desktop/common/detail-in-one.html', $pagedata);
}
}
}
示例8: destroy
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//dd("Eliminado".$id);
$user = User::findOrFail($id);
$message = $user->fullName . ' has been delete';
$user->delete();
if (request::ajax()) {
return response()->json(['message' => $message]);
}
//User::destroy($id);
Session::flash('message', $message);
return redirect()->route('admin.users.index');
}