【发布时间】:2016-10-19 12:55:54
【问题描述】:
为什么ajax post使用短url时无法加载页面?
当我在这样的 ajax 帖子中使用短 URL test.php 时
<script>
function send_username_value_for_check_available() {
$.ajax
(
{
url: 'test.php',
type: 'POST',
data: $('#username_send_value_fid').serialize(),
cache: false,
success: function (data) {
$('#mySpan_username').show();
$('#mySpan_username').html(data);
}
}
)
}
</script>
我会出错
XMLHttpRequest cannot load https://example.com/test.php. Response for preflight is invalid (redirect)
但是当我使用完整的 URL https://www.example.com/test.php 时效果很好。
如何在 ajax 帖子中使用短网址?
【问题讨论】:
-
preflight- 让它看起来跨原点......多么奇怪 -
我可以用 .htaccess 解决这个问题吗
-
页面
./test.php是否正在重定向到其他页面?
标签: javascript php jquery ajax .htaccess