【问题标题】:Base href confuse function on jquery and php includesjquery和php上的基本href混淆功能包括
【发布时间】:2013-08-02 12:11:36
【问题描述】:

我有密码

<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 方法中,我是否需要插入../?谢谢。。

【问题讨论】:

    标签: php jquery include href .post


    【解决方案1】:

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

    如果您想找到解决方法,应该在这里 What is the best way to set up base url for ajax request using Jquery?

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

    【讨论】:

    • 不,都在你的HTML视图里,和php无关
    猜你喜欢
    • 2012-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-13
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 2015-03-13
    相关资源
    最近更新 更多