duanlu4371 2015-10-08 07:30
浏览 588
已采纳

将不再重定向 - 302状态代码

Hey guys I got a 302 error code when I want to redirect my page, I'm using header()

I searched over google if I could find anything but I found nothing that was relevant for me, so maybe you guys can find it ;)

I get in the network tab in element inspecting 2 responses 1 is of my posting function in jQuery and the other is of the header('Location: index.php'); and that gives a response within Reload page to pick up source code for: http://localhost/porfolio/index.php

I did the header('HTTP/1.1 200 OK'); cuz I saw it would force it to give it a 200 OK code. But when I did that it didn't even give the response of the header('Location: index.php');

I just wan't to redirect the person to index.php when he submitted and all fields are oke.

Response:

if (!empty($error))
{
    foreach ($error as $errors)
    {
        echo '<span class="glyphicon glyphicon-warning-sign" style="padding-right:5px; color:red;"></span><a class="errors" style="color:red;">' . $errors . '</a><br>';
    }
}
else
{
    header('Location: index.php');
    header('HTTP/1.1 200 OK');
}

Request

posting.done(function(data){
    var errors = $('<div>' + data + '</div>').find('.errors');
    if (errors.length > 0)
    {
        $("#gb-errors").slideDown().empty().append(data);
    }
    else
    {
        $("#gb-errors").slideUp().empty();
    }
});
  • 写回答

1条回答 默认 最新

  • douba8048 2015-10-08 07:34
    关注

    You cannot redirect the page within an ajax request. You can use JQuery redirects instead.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)