最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - access to restricted uri denied on jquery includes - works fine with www subdomain - Stack Overflow

programmeradmin0浏览0评论

For some reason the jquery includes on this page throws a 1012 error but only if I view this page from the domain without the www

.html

The error doesn't show up from the www subdomain.

.html

I could change the script src to include a full path name, I suppose that might solve the problem but wanted to ask why it's happening in the first place. And the remended fix.

Thanks

For some reason the jquery includes on this page throws a 1012 error but only if I view this page from the domain without the www

http://marchofdimes./ovulation_calendar.html

The error doesn't show up from the www subdomain.

http://www.marchofdimes./ovulation_calendar.html

I could change the script src to include a full path name, I suppose that might solve the problem but wanted to ask why it's happening in the first place. And the remended fix.

Thanks

Share Improve this question asked Nov 4, 2010 at 18:52 rafirafi 431 silver badge7 bronze badges 4
  • problem also seems specific to firefox and IE. doesn't show up in chrome. guess it's because of security settings? – rafi Commented Nov 4, 2010 at 18:53
  • 1 Apart from lots of CSS errors I get this one in FF 4b6 for www-less: Error: uncaught exception: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "chrome://yslow/content/yslow-firefox-net.js Line: 444"] and this for the URL with www: Error: uncaught exception: [Exception... "Component returned failure code: 0x804b0002 (NS_BINDING_ABORTED) [nsIStreamListener.onDataAvailable]" nsresult: "0x804b0002 (NS_BINDING_ABORTED)" location: "JS frame :: chrome://yslow/content/yslow-firefox-net.js :: anonymous :: line 476" data: no] – Marcel Korpel Commented Nov 4, 2010 at 18:58
  • There are other problems with that page: when a dropdown menu is opened (e.g., 'cycle length'), the information box is hidden beneath it. And it doesn't show me when I should have intercourse. – Marcel Korpel Commented Nov 4, 2010 at 19:04
  • Thanks Marcel. Yeah, I'm aware that there's lots of issues with the css/html. But my cries to the relevant parties fall on deaf ears so I'm just working on my piece - making sure the calendar works properly. The intercourse icon is for logged in users only! It's more of an intercourse logging tool than anything else... The fertile/ovulation days are presumably the days people should have intercourse if they're trying to conceive. – rafi Commented Nov 5, 2010 at 5:43
Add a ment  | 

2 Answers 2

Reset to default 5

The problem is the ajax call you make with this line

$("#result_message").load('http://www.marchofdimes./hs.xsl/oc_Form.xml',..

change it to

$("#result_message").load('/hs.xsl/oc_Form.xml',...

The issue is that an ajax call from the non-www to the www violates the same origin policy

more info at

  • http://en.wikipedia/wiki/Same_origin_policy
  • https://developer.mozilla/En/Same_origin_policy_for_JavaScript

You have:

$("#result_message").load('http://www.marchofdimes./hs.xsl/oc_Form.xml', { //ajax call to dynament 

www.marchofdimes. is a different hostname to marchofdimes., so you hit the same origin policy.

Use a relative URI (i.e. one that starts with a /hs.xsl and not http://.

Alternatively, pick one hostname to be canonical and redirect (with a 301 status) all requests from the other to it.

发布评论

评论列表(0)

  1. 暂无评论