Error: [Exception… “Access to restricted URI denied” … while calling $.ajax method

↘锁芯ラ 提交于 2019-12-13 03:29:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!