Jquery.load URL from different folder
Jquery.load URL from different folder
如果我的文件在不同的文件夹中,如何使用.load
?
我试过:
$("#messageWindow").load("http://localhost/MainFolder/Messanging/index.php");
$("#messageWindow").load("Messanging/index.php");
$("#messageWindow").load("../Messanging/index.php");
没有任何效果,我已经阅读了有关使用 URL 时different folders
的主题,但我似乎无法让他们的答案起作用。
谢谢。
好的,我已经解决了The 1st and 2nd URL above WORKS
的问题,但我有另一个问题。index.php
有大量的网址。
<script type="text/javascript" src="../js/jquery-1.7.2.min.js"></script>
<script src="../plugins/ui/jquery.ui.core.js"></script>
<script src="../plugins/ui/jquery.ui.widget.js"></script>
<script src="../plugins/ui/jquery.ui.datepicker.js"></script>
<script src="../plugins/timezone/jstz.min.js"></script>
<script type="text/javascript" src="file_js/index.js"></script>
但是现在这些URls不再工作了,我采取的解决方案是添加整个URL。
<script type="text/javascript" src="http://localhost/MainFolder/js/jquery-1.7.2.min.js"></script>
<script src="http://localhost/MainFolder/plugins/ui/jquery.ui.core.js"></script>
<script src="http://localhost/MainFolder/plugins/ui/jquery.ui.widget.js"></script>
<script src="http://localhost/MainFolder/plugins/ui/jquery.ui.datepicker.js"></script>
<script src="http://localhost/MainFolder/plugins/timezone/jstz.min.js"></script>
<script type="text/javascript" src="http://localhost/MainFolder/Messanging/file_js/index.js"></script>
如果我将文件上传到我的网络主机,这将是一种喧嚣。我认为使用相对路径可以解决问题,但我不知道它是如何工作的。
对于 jQuery load()
,您可以包含当前页面的相对路径或绝对路径。如果您在 JS 控制台或 firebug 中运行以下命令,您应该会在浏览器中看到两次相同的问题。
$("#header").load("/questions/10643503/jquery-load-url-from-different-folder");
内容还需要来自与原始页面相同的来源(您只能加载来自同一域的内容(。
相关文章:
- 使用指令的angular js中的Like和different
- iframe and JavaScript on different pages
- jquery onclick or onchange on different elements
- Array.prototype.fill() different from fill as I go
- Get latlng from different addresses using PHP & JavaScri
- different between LocalStorageModule and localStorageService
- Different date time formatting output on java & moment j
- 从带有 index.js 的“/folder”导入 JavaScript
- Jquery.load URL from different folder
- jQuery load() when on a different tab
- Different between $('#id') vs $(id)?
- Different in Java SHA1 vs JavaScript SHA1
- Ajax发送一个get-to-original页面,而不是一个post-to-different页面
- Uploadify FOLDER
- 如何在其他grunt任务中使用grunt-folder-list生成的结果
- 如何只使用JSP和javascript显示浏览FOLDER窗口(而不是浏览文件)
- Show different content if 'ko with' is not displayed
- Different result from JavaScript RegExp in "rhino1.7.6&
- 使用jquery加载different css