为什么IE7和IE8给我“访问被拒绝"?调用jQuery时? [英] Why is IE7 and IE8 Giving me "Access Denied" when calling jQuery?
问题描述
我正在使用Google CDN将jQuery 1.4.2 Min File调用到我的应用程序中.一款FF,Chrome,Safari一切正常.但是由于某种原因,我在第127行收到了jquery.min.js文件的访问被拒绝"错误...?我不明白任何人都知道为什么这样行事吗?我完全一无所知.
!
截屏
I am using the Google CDN to call the jQuery 1.4.2 Min File into my application. One FF, Chrome, Safari everything is working great. But for some reason, i get a "Access Denied" error for the jquery.min.js file on line 127...? I don't get it. Anyone have a clue why this is acting up in this way? I am totally clueless.
!
Screenshot
代码
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
type="text/javascript"></script>
.
case 1:
methodName = "SavePropertyInformation";
var HasFoundProperty, PropertyType, NumberOfUnits,
PropertyAddress, PropertyCity, PropertyState,
PropertyZipCode, PropertyCounty;
HasFoundProperty = $("#foundProperty input[type='radio']:checked").val();
PropertyType = $('#<%= this.fvApp.FindControl("ddlPropertyType").ClientID %>').val();
NumberOfUnits = $('#<%= this.fvApp.FindControl("ddlNumberOfUnits").ClientID %>').val();
PropertyAddress = $('#<%= this.fvApp.FindControl("txtPropertyAddress").ClientID %>').val();
PropertyCity = $('#<%= this.fvApp.FindControl("txtPropertyCity").ClientID %>').val();
PropertyState = $('#<%= this.fvApp.FindControl("ddlPropertyState").ClientID %>').val();
PropertyZipCode = $('#<%= this.fvApp.FindControl("txtPropertyZipCode").ClientID %>').val();
GetCountyFromZipCode(PropertyZipCode);
PropertyCounty = GetCounty();
data = "{WebAccessID:'" + WebAccessID + "', HasFoundProperty:'" + HasFoundProperty + "', PropertyType:'" + PropertyType + "', NumberOfUnits: '"
+ NumberOfUnits + "', PropertyAddress: '" + PropertyAddress + "', PropertyCity:'" + PropertyCity
+ "', PropertyState:'" + PropertyState + "', PropertyZipCode:'" + PropertyZipCode + "',PropertyCounty:'"
+ PropertyCounty + "' }";
doAjaxReq(methodName, data, showSavingDialog);
break;
推荐答案
由于 document.domain 以避免被Same Origin策略拒绝访问.
Making a call to a sub domain is seen as a different domain because of the Same Origin policy. Make sure that you are setting document.domain to avoid access denied with the Same Origin policy.
要同步document.domain,您需要在两个位置进行设置.添加一个用于设置域的脚本标签,然后您需要在页面上具有一个iframe,以便在另一个域上设置相同的内容.
To get the document.domain in sync you need to set it in two places. Add a script tag that set the domain, and you need to have an iframe on the page that sets the same thing on the other domain.
通过"www.example.com"进行Ajax调用并正在调用"ajax.example.com"的页面:
The page that the Ajax call is made from "www.example.com" and is calling "ajax.example.com":
<script type="text/javascript">
document.domain = "example.com";
</script>
<iframe src="http://ajax.example.com/domainCode.html"></iframe>
"domainCode.html"将仅包含脚本标记
The "domainCode.html" would just contain the script tag
<html>
<head>
<script type="text/javascript">
document.domain = "example.com";
</script>
</head>
<body>
</body>
</html>
有了这个,您应该能够在子域之间进行通话.
With that in place you should be able to talk between your sub domains.
这篇关于为什么IE7和IE8给我“访问被拒绝"?调用jQuery时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!