在php中通过json_编码重定向
这是我的代码,我想在执行此代码后重定向页面只需使用headerLocation:your_page.php;死前在php中通过json_编码重定向,php,json,redirect,Php,Json,Redirect,这是我的代码,我想在执行此代码后重定向页面只需使用headerLocation:your_page.php;死前 if ($this->register($email, $register_status)) { $this->sendConfirmationEmail($email); echo json_encode(array("message"
if ($this->register($email, $register_status))
{
$this->sendConfirmationEmail($email);
echo json_encode(array("message" => $this->error = $this->l('Your email was registered. Thank You!'),"code" => 1));
die();
}
如果错误
添加第一行浇头
if ($this->register($email, $register_status))
{
$this->sendConfirmationEmail($email);
echo json_encode(array("message" => $this->error = $this->l('Your email was registered. Thank You!'),"code" => 1));
header("Location: your_page.php");
die();
}
只需使用headerLocation:your_page.php;死前功能!!其中是显示错误XMLHttpRequest无法加载的issuesits。请求的资源上不存在“Access Control Allow Origin”标头。因此不允许访问“来源”。请查看此帖子,这可能会有所帮助http://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource
<?php
ob_start();
if ($this->register($email, $register_status))
{
$this->sendConfirmationEmail($email);
echo json_encode(array("message" => $this->error = $this->l('Your email was registered. Thank You!'),"code" => 1));
header("Location: your_page.php");
die();
}?>