jquery和php上的基本href混淆函数包含


Base href confuse function on jquery and php includes

我有代码

<base href = "http://localhost/thebaseaddress/">

如果我目前正在处理该地址内的文件夹(例如newFolder),并在该文件夹上的文件内使用该文件夹(例如,index.php),这是否会影响我从父目录(如)访问文件的jquery .post方法

<base href = "http://localhost/thebaseaddress/">
//jquery
$.post('otherFolder/file.php', { passed: passed }, function(data) { 
});

请注意,otherFolder/file.php位于newFolder目录之外,位于父目录上。

结构:

thebaseaddress
   newFolder
        index.php
   otherFolder
        file.php
        anyFile1.php
        anyFile2.php

然后在index.php中,我也有这个:

include 'otherFolder/anyFile1.php';
include 'otherFolder/anyFile2.php';

我应该在.post中使用../吗?还是因为我有base href而不再使用?同样在include方法中,我需要插入../吗?Thankz。。

该基本标记不会像在HTML文档上那样自动解析jQuery ajax请求中的相对URL。

如果你想找到解决方法,它应该在这里使用Jquery为ajax请求设置基本url的最佳方法是什么?

它们提供了一种将基href与您想要放入ajax 的任何子url连接起来的方法