jQuery加载在Dreamweaver上,但不在浏览器中 [英] jQuery load works on Dreamweaver but not in browsers

查看:186
本文介绍了jQuery加载在Dreamweaver上,但不在浏览器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了 .load()函数。

这是我的 HTML 部分:

<script src="js/jquery.js"></script>
<script src="tabsPull.js"></script>
<h1>Homework Assignments</h1>
<ul id="button-menu">
    <li id="a1"><input class="no" type="button" onClick="ChangeActive(1)" value="Mon"></li>
    <li id="a2"><input class="no" type="button" onClick="ChangeActive(2)" value="Tues/Wed"></li>
    <li id="a3"><input c    lass="no" type="button" onClick="ChangeActive(3)" value="Thurs/Fri"></li>
</ul>
<div id="tabInner" class="tabInner">

</div>

ChangeActive()位于单独的 JS 文件tabsPull.js)::

The ChangeActive() is in a separate JS file (tabsPull.js):

var active = 0
function ChangeActive(active){
    if (active==1) {
        document.getElementById("a1").className = "active";
        document.getElementById("a2").className = "";
        document.getElementById("a3").className = "";
        $('#tabInner').load('http://axoplanner.weebly.com/monday.html #content');
    } else if (active==2) {
        document.getElementById("a2").className = "active";
        document.getElementById("a1").className = "";
        document.getElementById("a3").className = "";
        $('#tabInner').load('http://axoplanner.weebly.com/tuesdaywednesday.html #content');
    } else if (active==3) {
        document.getElementById("a3").className = "active";
        document.getElementById("a1").className = "";
        document.getElementById("a2").className = "";
        $('#tabInner').load('http://axoplanner.weebly.com/thursdayfriday.html #content');
    }
}

有什么问题?它工作在DW,但为什么不是浏览器?我从Weebly拉取东西的原因是因为我需要其他人更新它,Weebly更容易。

What's the problem? It works in DW, but why not the browsers??? The reason I pull things from Weebly is because I need others to update it, and Weebly is easier.

推荐答案

=http://api.jquery.com/load/ =nofollow>此页面。

See this page from the jQUery documentation.

从文档

由于浏览器安全限制,大多数Ajax请求都遵循相同的源策略;请求无法成功检索数据来自不同的域,子域或协议。

"Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol."

因此,DreamWeaver不能具有大多数浏览器所具有的安全限制,因此它可以在DreamWeaver中使用。但在绝大多数浏览器中绝对路径不会作为 .load()的参数。

So, DreamWeaver must not have the security restrictions that most browsers have, so it works in DreamWeaver. But an absolute path will not work as an argument for .load() in most browsers.

这篇关于jQuery加载在Dreamweaver上,但不在浏览器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆