问题
I am getting this error while calling $.ajax methods
Error: [Exception... "Access to restricted URI denied" code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)" location: "xxxxxx" Line: 19"] Source File: xxxxxxxxx Line: 19
I am passing URL paramter as http://www.xyz.com/myscriptfolder/myfile.js .
The $.ajax method works well when i have the url in the broswer as http://www.xyz.com but it won't work when I have th url in browser like http://xyz.com
Could you suggest me any workaround for it. I have to keep the URL paramter in the form http://..... Also it is not the case of cross domain issue, as i am trying to access the files from the same domain.
回答1:
You are not allowed to make AJAX requests on another domain, and when the url paths do not match, it thinks they are on different domains.
edit: could you pass the relative url, instead of full path as a workaround? i.e. /path/to/file.aspx instead of http://www.xyz.com/path/to/file.aspx?
来源:https://stackoverflow.com/questions/1758183/error-exception-access-to-restricted-uri-denied-while-calling-ajax