Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is IE7 and IE8 Giving me "Access Denied" when calling jQuery?

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

Code

<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;
like image 921
Reaction21 Avatar asked Aug 12 '10 18:08

Reaction21


1 Answers

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.

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.

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>

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.

like image 135
epascarello Avatar answered Nov 05 '22 14:11

epascarello