使用PHP中的标头(位置)和jQuery Mobile [英] Using header(location) in PHP with jQuery Mobile

查看:166
本文介绍了使用PHP中的标头(位置)和jQuery Mobile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

准确地说,开始使用jQuery和jQuery mobile。我在PHP中编写了一个登录脚本,一旦用户成功登录,就运行以下内容:

Just starting to play with jQuery and jQuery mobile to be exact. I've written a login script in PHP that once the user has successfully logged in runs the following:

header(Location:index.php );

我希望应用程序做的是将用户重定向到他们

What I want the application to do is redirect the user to th em

当它运行时,我收到以下错误:

When that runs though, I get the following error:

警告:无法修改标头信息 - 已经发送的标头(输出已启动) at /Applications/MAMP/htdocs/app/login.php:22)在第138行的/Applications/MAMP/htdocs/app/login.php中

用户已登录,此处没有问题。当我输入主页面的URL(index.php)并刷新它时,会话变量被设置等。

The user is logged in, there isn't a problem there. When I enter the URL of the main page (index.php) and refresh it, the session variables are set etc.

我认为jQuery Mobile正在发布一些东西在后端导致标题被发送。

I'm thinking that jQuery Mobile is posting something in the back end that's causing headers to be sent.

任何想法?谢谢!

推荐答案

jQuery Mobile只是javascript javascript。当php脚本运行时,它无法执行任何操作。它仅适用于浏览器。

jQuery Mobile is JUST javascript. It can't do anything while a php script is running. It works solely in the browser.

问题是第22行的login.php输出了一些内容。您必须在任何 echo ... print()之前发送标题,并且在任何<$ c $之前c>?>

The problem is that login.php in line 22 outputs something. You must send headers before any echo ... or print() is ever made AND before any ?>

这篇关于使用PHP中的标头(位置)和jQuery Mobile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆