为什么jQuery会阻止propper 301重定向?

问题描述 投票:0回答:1

我想在html文件中加载jquery和jquery移动库的表单后重定向301。

这种方式不能按预期工作,因为目标更改,但URL保留在浏览器中,此后会产生一些问题。

HTML文件,保存为UTF-8 unix:

<!DOCTYPE html>
<html lang="DE">
<head>
    <title>redirect test</title>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js"></script>

</head>
<body>

    <form action ="/subapp_search/filter_results_redir.php" method="POST">
        <input type="submit">test
    </form>

</body>
</html>

PHP动作文件,保存为UTF-8 unix,名称:/dir/filter_results_redir.php

<?php
    header("Location: /", TRUE, 301);
    exit;
?>

使用此代码,浏览器URL窗口将显示POST URL:dir/filter_results_redir.php和redirect。

删除两个jQuery库中的任何一个都可以解决问题,显示的URL将更改为/并重定向

我尝试了绝对和相对URL。 Servier是Apache 2.4.18

Request URL: http://rex.local/subapp_search/filter_results_redir.php
Request Method: POST
Status Code: 301 Moved Permanently
Remote Address: 192.143.56.200:80
Referrer Policy: no-referrer-when-downgrade
Connection: Keep-Alive
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Tue, 19 Mar 2019 05:51:07 GMT
Keep-Alive: timeout=5, max=100
Location: /
Server: Apache/2.4.18 (Ubuntu)
Accept: text/html, */*; q=0.01
Accept-Encoding: gzip, deflate
Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
AlexaToolbar-ALX_NS_PH: AlexaToolbar/alx-4.0.3
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 0
Cookie: user_cls=a%3A9%3A%7Bi%3A0%3Bi%3A961992%3Bi%3A1%3Bi%3A961993%3Bi%3A2%3Bi%3A961994%3Bi%3A3%3Bi%3A961995%3Bi%3A4%3Bi%3A961996%3Bi%3A5%3Bi%3A961997%3Bi%3A6%3Bi%3A961998%3Bi%3A7%3Bi%3A962004%3Bi%3A8%3Bi%3A962005%3B%7D; test_cookie=e8e; new_cl=vfn5kj4stc115ri78td0qt8r13; findix_counter=a%3A5%3A%7Bi%3A0%3Bs%3A6%3A%22961944%22%3Bi%3A1%3Bs%3A6%3A%22961960%22%3Bi%3A2%3Bs%3A6%3A%22961940%22%3Bi%3A3%3Bs%3A6%3A%22960238%22%3Bi%3A4%3Bs%3A6%3A%22961952%22%3B%7D; session_localrexDE=4fb1bbbfa7db5a268d50d6a3ca4fef0b
Host: rex.local
Origin: http://rex.local
Pragma: no-cache
Referer: http://rex.local/subapp_search/filter_results_redir.php
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36
X-Requested-With: XMLHttpRequest
jquery apache redirect jquery-mobile url-redirection
1个回答
0
投票

我终于解决了,但我不明白这个问题。相同的代码行有效,而另一行则没有。

首先要做的是,将数据-ajax =“false”添加到代码中。但这并没有解决它。

此代码不起作用:

<form method="post" action="/filter_results_redir.php" data-ajax=”false” >

这段代码确实有效:

<form method="post" action="/filter_results_redir.php" data-ajax="false">

它看起来完全一样。复制粘贴不起作用,我再次逐字写行,然后它工作。

© www.soinside.com 2019 - 2024. All rights reserved.