【发布时间】:2016-03-21 12:32:55
【问题描述】:
我正在尝试重定向到其他页面(例如 google),但它不起作用。这是代码:
function algo(a) {
$.get("links/privado/verlink.php?" + a, function(data, status) {
document.getElementById("algunacosa").href = data;
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a id="algunacosa">Ir al link</a>
<button onclick="algo">Retrive link</button>
如果响应是:http://google.com 它会将我重定向到 http://mrvikxd.ddns.net/m/http://google.com 并出现 403 错误
编辑:我在 Google Chrome 开发控制台上看到了代码,<a id="algunacosa"> 的 href 是 href="http://google.com"。我不知道为什么它没有转到 Google。
【问题讨论】:
-
我无法重现该问题。我只能假设
links/privado/verlink.php没有返回您认为返回的内容。 -
愿你在
data中分享你从服务器获得的确切信息;
标签: javascript jquery html ajax redirect