Содержание
- Ns error dom bad url
- Answered by:
- Question
- Answers
- All replies
- «http block» & protected area = NS_ERROR_DOM_BAD_URI: Access to restricted URI denied #1583
- Comments
- Ошибка API Soundcloud NS_ERROR_DOM_BAD_URI: доступ к ограниченному URI запрещен (JavaScript)
Ns error dom bad url
Answered by:
Question
I am trying to access the data from WebAPI in a MVC application. I am able to call the WebAPI successfully and WebAPI is returning the data as well but data is not being displayed on UI.
When I tried checking the request in firebug can see the call for WebAPI with error «application/json (NS_ERROR_DOM_BAD_URI)»
Any idea, how can I fix this error
Answers
for accessing a new site you required jsonp request, not json.
thanks everyone Who responded, I was able to call my APi successfully using JSOP and the following article helped with ->
Try the following url
If the above URL does not work then try the following code instead
Hope this solve your problem
Mirrh — WebAPI is a different project from the MVC application, without full URL how/where it will search for WebAPi controller?
if this is in the same project, try
no this is not the same project.
ok, in that case, is the project with the API running when you try and access the API?
try using fiddler, and make a call to your api http://localhost:16639/api/blog/
yes it is running and as mentioned in my first post, I am able to call the API project (debug points are hitting) and data is returned from the API however no data is being received my web project
for accessing a new site you required jsonp request, not json.
ignatandrei — I am not sure if JSONP is something really required in my case because I have both projects in Localhost only and no cross doamin calls.
I have seen some posts which are performing the same kind of functionality using simple JSON data which I would expect to work. At the moment, I am not worried out the structure of the data, I am just trying to get the data from one webAPI project to other MVC application which should be really straight forward.
Источник
«http block» & protected area = NS_ERROR_DOM_BAD_URI: Access to restricted URI denied #1583
I am testing Snap! ‘s «http block». I want to read from a file by using a PHP script on my webspace. This works well via:
http://. mywebspace. /index.php?type=read&filename=test.txt
(If necessary, I will send the PHP script.) Now, I protected the webspace via .htaccess and .htpasswd . When I send the http request by using a browser’s address bar, I get the desired result:
http://user:password@. mywebspace. /index.php?type=read&filename=test.txt
Sadly, this does not work with Snap! ‘s «http block». Here, I get:
NS_ERROR_DOM_BAD_URI: Access to restricted URI denied
Can you help me?
The text was updated successfully, but these errors were encountered:
Maybe you should set header Authorization by using JSFunction block.
@dekrain Thank you. I guess, I might need a little more help. Here is my try, which is not working by now:
For I am not quite experienced with JavaScript, I hoped, that I could avoid the » JavaScript function block». So, in order to set a header, I imported Snap! ‘s library Web services access (https) . Now I made this block:
You must encode this with btoa function.
dGVzdDpwYXNz is encoded test:pass that means test user with pass password.
Second thing: use (LIST (list [Auth. ] [Basic. ])) .
By the way, btoa is a JavaScript function:
You can use a JS Function block to get btoa in Snap!:
Second thing: use (LIST (list [Auth. ] [Basic. ])).
This shouldn’t be necessary. Headers is automatically a list because it’s a variadic input.
By the way, I did working btoa function in Snap! using JavaScript encode algorithm. It’s one of my cloud project.
@cycomachead ouch, now I see. The arrow after list block.
I think you guys are not getting that the OP doesn’t want to have to learn JS, but is asking for a turnkey solution. Pretend this was posted on the user forum thread instead of on github.
Thank you for your support. In addition to the posting of @brianharvey: As a teacher, I am aiming to use Snap! in an educational project (not necessarily JavaScript — just to stay focussed). I wanted to rebuild some of the ideas presented in SQLsnap! ( http://snapextensions.uni-goettingen.de/ ), which is based on Snap! -beta-sourcecode from December 2013.
If there is a more appropriate forum, feel free to redirect me.
My next approach was not successfull. Any suggestions?
That looks like it should work..
I think we need more info:
Can you post the full URL? (without the password)
Are you using snap.berkeley.edu or something offline?
Does pasting the same URL work in a browser? (with embedding the password in the URL).
Can you post the full URL? (without the password)
You can find my website here:
http://phagedaenic-cans.000webhostapp.com/index.php?type=read&filename=test.txt
You can use the user user with the password password .
Are you using snap.berkeley.edu or something offline?
I am using snap.berkeley.edu .
Does pasting the same URL work in a browser? (with embedding the password in the URL).
This works fine:
http://user:password@phagedaenic-cans.000webhostapp.com/index.php?type=read&filename=test.txt
You should get a simple hello .
Of course, publishing URL and password is a serious security issue. It is just for the purpose of testing and will be deleted afterwards.
I can’t reproduce the same error. Here’s what I do see:
Take a look at enable-cors.org for info on getting around that. It seems like your URL and site should work just fine otherwise.
Thank you for the response. I think, it ‘s a newbie question, but where do you saw the error message, @cycomachead? I just got a small, empty balloon.
I read the instructions on enable-cors.org , but I still don’t know, how to solve the problem.
If my website is not password protected, I have to add the line header(«Access-Control-Allow-Origin: *»); to my PHP file to get a success.
If I use password protection via .htaccess and .htpasswd , this is not enough. So I added the line Header set Access-Control-Allow-Origin «*» to my .htaccess file — still no success. As mentioned on enable-cors.org , I have to reload Apache. I am not quite experienced in these things, but I don’t think that I can do this while using the free services of my provider. I am only allowed to upload files.
I would be glad, if someone can help me out.
My problem is partly solved.
I use Debian GNU/Linux stable. When I start the chromium webbrowser via chromium —disable-web-security —user-data-dir , I get the expected result. Sadly, this still does not work with the iceweasel webbrowser. Of course, I intend to get a browser independent solution. Any suggestions?
Thank you very much. This is quite helpful.
Hopefully, someone can help me out with the eagerly-awaited browser independent solution. I want to use Snap! ‘s «http block» in an educational project. It would be great, if my students could use the feature without keeping an eye on the appropriate browser configuration. In addition, I think some students might get motivated in starting their own projects with free PHP webspace. Therefore, it would be nice, if the project would work just by dropping a few files on the server. I want to stay focussed on a project, that mainly uses Snap! .
A few days ago, I wrote:
Hopefully, someone can help me out with the eagerly-awaited browser independent solution.
I checked out some websites regarding my topic — for instance https://awesometoast.com/cors/ . I think, I just have to do the appropriate configuration using the .htaccess file. I tried my best, but I still did not find a way to succeed.
It would be great, if someone could help me. If I could not find help here: Do you know the appropriate forum for my problem?
Источник
Ошибка API Soundcloud NS_ERROR_DOM_BAD_URI: доступ к ограниченному URI запрещен (JavaScript)
Я просто познакомился с Soundcloud API, и у меня проблемы. Насколько я могу судить, все, что мне нужно в SC.initialize , — client_id. Я использовал учебники в Академии Кодекса, чтобы начать, и это было здорово. Теперь, когда я на самом деле пытаюсь реализовать что-то, у меня возникают проблемы.
Когда я запустил свой код в Code Academy, он сделал именно то, что хотел. Теперь, когда я пытаюсь запустить его в браузере, я получаю пустой экран и эту ошибку:
NS_ERROR_DOM_BAD_URI: запрещен доступ к ограниченному URI @ http://connect.soundcloud.com/sdk
После некоторых исследований я обнаружил, что эти ошибки связаны с префиксами домена. Поэтому я попытался изменить его на http:// www. connect.soundcloud.com/sdk. Но когда я это делаю, я получаю другую ошибку:
AHHHH Что я делаю неправильно?! Я новичок в использовании API, и любая помощь вообще будет очень оценена. Вот что я делаю:
(JavaScript)
Я действительно не думаю, что с кодом что-то не так, так как все, казалось, отлично работает в Code Academy. Я думаю, что это больше проблема с ознакомлением с API. Нужно ли выполнять дополнительную проверку подлинности? Мне нужно что-то большее, чем просто идентификатор клиента? Снова я очень застрял и буду благодарен за любую помощь в этом. Спасибо за чтение.
(Я также поступил вместе с Coding for GOOD Soundcloud API Integration tutorial, и я получаю точные точные ошибки, поэтому это еще раз подтверждает, что код, вероятно, не проблема, но подключение к API может быть )
Источник
Answer by Izabella Cobb
You are encountering a same-origin-policy issue (see http://en.wikipedia.org/wiki/Same-origin_policy). This means that either the port, domain, or protocol is not the same between the URI that you are sending a request TO and the URL that you are sending the request FROM.,Please be sure to answer the question. Provide details and share your research!,
What would be the pitfalls and potentially overpowered exploits of an event/action recording and replay magic system?
,
What is this curve going upwards to a note that’s also detached from the previous note?
FE code:
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json'
}
BE code (Spring Boot):
allowedHeaders("userLoginToken", "Content-Type")
Answer by Derrick Campbell
NS_ERROR_DOM_BAD_URI: Access to restricted URI denied,Doing tests locally on my computer:,I have resolve NS_ERROR_DOM_BAD_URI error in my project (using ReactJS — handle API by axios) but I think my explaination an solution can help you:,Because I only allow ‘Content-Type’ in headers, but my header have redundant config ‘Access-Control-Allow-Origin’ and my BE not allow that.
index.hml
<!DOCTYPE html>
<html>
<head>
<!--script src="angular.js"></script-->
<script src="i18next.js"></script>
<script src="app.js"></script>
</head>
<body>
</body>
</html>
app.js
i18n.init();
Error @ line 672 in i18next.js
xhr.send(payload);
Answer by Cayden Mendoza
It’s means you are loading some content that are not belong to or located at your site (different domain name). See this jQuery example to load the cross domain (yahoo.com) content on demand.,This jQuery error message is caused by loading the cross domain content.,Here’s a dirty workaround – Get the cross domain content with server side language. For example, create a one line php file named “proxy.php”.,In jQuery side, change the load function to
This jQuery error message is caused by loading the cross domain content.
Error: [Exception... "Access to restricted URI denied"
code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)"
It’s means you are loading some content that are not belong to or located at your site (different domain name). See this jQuery example to load the cross domain (yahoo.com) content on demand.
<html>
<head>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<style type="text/css">
#content{
border:1px solid blue;
margin:16px;
padding:16px;
}
</style>
</head>
<body>
<div id="msg"></div>
<div id="content">
</div>
<br/>
<button id="load">Load yahoo.com</button>
<script type="text/javascript">
$('#load').click(function(){
$('#msg').text("Loading......");
$('#content').load("http://www.yahoo.com", function() {
$('#msg').text("");
});
});
</script>
</body>
</html>
proxy.php
<?php echo file_get_contents($_GET['url']);?>
In jQuery side, change the load function to
$('#load').click(function(){
$('#msg').text("Loading......");
$('#content').load("proxy.php?url=http://www.yahoo.com", function() {
$('#msg').text("");
});
});
</script>
Answer by Saul Cordova
When I run the index.html, I get the error message NS_ERROR_DO$$anonymous$$_BAD_URI: Access to restricted URI denied., If you are a new user to Unity Answers, check out our FAQ for more information., This site uses strictly necessary cookies. More Information,Do Not Sell My Personal Information
My code so far:
<script type="text/javascript"src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
var unityObjectUrl = "http://webplayer.unity3d.com/download_webplayer- 3.x/3.0/uo/UnityObject2.js";
if (document.location.protocol == 'https:')
unityObjectUrl = unityObjectUrl.replace("http://", "https://ssl-");
document.write('<script type="text/javascript" src="' + unityObjectUrl + '"></script>');
</script>
<script type="text/javascript" language="javascript">
var u = new UnityObject2();
var t = document.getElementById("btn1");
$(document).ready(function(){
$("#btn1").click(function(){
u.initPlugin(jQuery(t), "unityObjectUrl.unity3d");
SaySomethingToUnity();
});
function SaySomethingToUnity()
{
u.getUnity().SendMessage("Button", "getMensageFromWeb", "Hello");
}
function getFromUnity( arg )
{
alert( arg );
}});
</script>
Answer by Maya Day
У меня есть html-файл с несколькими D3-графами, непосредственно записанными в теги скриптов. Когда я передаю один из графиков на аутсорсинг во внешний JS-файл, я получаю это сообщение «NS_ERROR_DOM_BAD_URI: Access to restricted URI denied». Если я удалю код с d3.json, где он читает локальный файл json, ошибка исчезнет. Но должна же быть возможность загрузить файл json во внешний js, который встроен в html, верно?
,
Я получаю эту ошибку при вызове методов $.ajax Ошибка: [Исключение… Access to restricted URI denied код: 1012 nsresult: 0x805303f4 (NS_ERROR_DOM_BAD_URI) местоположение: xxxxxx строка: 19]…
,
i18n: NS_ERROR_DOM_BAD_URI: доступ к restricted URI запрещен
,
Я получаю эту ошибку при вызове методов $.ajax Ошибка: [Исключение… Access to restricted URI denied код: 1012 nsresult: 0x805303f4 (NS_ERROR_DOM_BAD_URI) местоположение: xxxxxx строка: 19] Исходный файл: xxxxxxxxx Строка: 19 Я передаю URL paramter как http://www.xyz.com/myscriptfolder/myfile.js…
У меня есть html-файл с несколькими D3-графами, непосредственно записанными в теги скриптов. Когда я передаю один из графиков на аутсорсинг во внешний JS-файл, я получаю это сообщение «NS_ERROR_DOM_BAD_URI: Access to restricted URI denied». Если я удалю код с d3.json, где он читает локальный файл json, ошибка исчезнет. Но должна же быть возможность загрузить файл json во внешний js, который встроен в html, верно?
d3.json("forcetree.json", function(json) {
root = json;
update();
});
Answer by Lena Frye
That does not work, since the OSRM server URL uses a protocol relative URL. Please serve the example through an HTTP server. (I recommend NPM’s http-server — install it globally and you can set up a static HTTP server anywhere in absolutely no time and with no fuss.),That is problematic, for example when developing with FirefoxOS simulator.,
The text was updated successfully, but these errors were encountered:
,Using the serviceUrl option, you can set the URL to anything you like!
L.Routing.control({
router: L.Routing.osrm({ serviceUrl:"https://router.project-osrm.org/viaroute"} ),
waypoints: [
L.latLng(57.74, 11.94),
L.latLng(57.6792, 11.949)
]
}).addTo(map);
Answer by Everleigh O’Donnell
NS_ERROR_DOM_BAD_URI: Access to restricted URI denied,javascript – i18n: NS_ERROR_DOM_BAD_URI: Access to restricted URI denied – Stack Overflow,转载请注明:在路上 » 【未解决】js中用XMLHttpRequest加载html出错:NS_ERROR_DOM_BAD_URI: Access to restricted URI denied,jQuery – Access to restricted URI denied – Solution
期间,使用代码:
function loadPage(href)
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", href, false);
xmlhttp.send();
return xmlhttp.responseText;
}
function editSavedGoodsContent()
{
var kindeditor = window.editor;
// 加载之前已保存的页面的HTML内容
savedHtmlHref = "previous_saved_page.html";
<!-- html = kindeditor.html(savedHtmlHref); -->
<!-- var loadedHtml = $("#easyui_editor").load(savedHtmlHref); -->
loadedHtml = loadPage(savedHtmlHref);
console.log(loadedHtml);
kindeditor.html(loadedHtml);
}
试试:
document.getElementById("easyui_editor").innerHTML='<object type="text/html" data="previous_saved_page.html" ></object>';
对应的
<form>
<textarea name="easyui_editor" id="easyui_editor" class="easyui-kindeditor" style="width: 100%; height: 200px; ">在此输入新产品的介绍内容</textarea>
</form>
试试:
function editSavedGoodsContent()
{
var kindeditor = window.editor;
// 加载之前已保存的页面的HTML内容
savedHtmlHref = "previous_saved_page.html";
jQuery.ajax({
url: savedHtmlHref, dataType: "html"
}).done(function( responseHtml ) {
console.log(responseHtml);
$("#easyui_editor").html(responseHtml);
});
}
试试:
$.get(savedHtmlHref, function(data){
console.log("Data Loaded: " + data);
});
试了:
function editSavedGoodsContent()
{
console.log("into editSavedGoodsContent");
var kindeditor = window.editor;
/*
// 加载之前已保存的页面的HTML内容
var savedHtmlHref = "previous_saved_page.html";
html = kindeditor.html(savedHtmlHref);
var loadedHtml = $("#easyui_editor").load(savedHtmlHref);
loadedHtml = loadPage(savedHtmlHref);
document.getElementById("easyui_editor").innerHTML='<object type="text/html" data="previous_saved_page.html" ></object>';
kindeditor.sync();
console.log(loadedHtml);
kindeditor.html(loadedHtml);
*/
var savedHtmlHref = "previous_saved_page.html";
var loadedHtml = $.get(savedHtmlHref, function(data){
console.log("Data Loaded: " + data.toSource());
});
console.log("loadedHtml=" + loadedHtml);
//$("#mainFrame").load(savedHtmlHref);
//console.log("mainFrame Loaded");
}
Closed
Bug 417378
Opened 15 years ago
Closed 15 years ago
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
People
(Reporter: carglue, Unassigned)
References
Details
(Keywords: qawanted)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b3) Gecko/2008020514 Firefox/3.0b3 FireShot/0.32 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b3) Gecko/2008020514 Firefox/3.0b3 FireShot/0.32 Starting with Firefox 3 beta3, loading a local XML file via trusted chrome fails with the following error: "Access to restricted URI denied (NS_ERROR_DOM_BAD_URI)" Our Firefox extension has an XPCOM-based JavaScript component that creates an XML document object, then loads it with the contents of a local XML file using a valid local file URL string. Here's a stripped-down snippet of that part of the code: var domParser = CC["@mozilla.org/xmlextras/domparser;1"].createInstance(CI.nsIDOMParser); var domImpl = domParser.parseFromString("<?xml version='1.0' encoding='UTF-8' ?><dummy/>", "text/xml").implementation; var docObj = domImpl.doctype; var domTree = domImpl.createDocument("", "", null); domTree.async = false; domTree.load("file:///C:/d/y.xml"); The above code has been working fine for nearly 3 years, and also works fine in Firefox 3 beta2, as well as in all previous FF versions going back to at least 1.5. Reproducible: Always
Flags: blocking-firefox3?
See bug 397791. I have to ask: is there a reason not to just ParseFromStream on the file stream, or XMLHttpRequest, to start with? That would avoid creating the extra dummy document and so forth...
Version: unspecified → Trunk
Component: File Handling → DOM
Flags: blocking-firefox3?
Product: Firefox → Core
QA Contact: file.handling → general
Status: UNCONFIRMED → RESOLVED
Closed: 15 years ago
Resolution: — → WONTFIX
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
- Remove From My Forums
-
Question
-
User655789308 posted
I am trying to access the data from WebAPI in a MVC application. I am able to call the WebAPI successfully and WebAPI is returning the data as well but data is not being displayed on UI.
When I tried checking the request in firebug can see the call for WebAPI with error «application/json (NS_ERROR_DOM_BAD_URI)»
<script type="text/javascript" src="/jquery/jquery-1.3.2.min.js"></script> <script type="text/javascript" language="javascript"> $(document).ready(function () { $("#driver").click(function (event) { $.getJSON('http://localhost:16639/api/blog/', function (jd) { $('#stage').html('<p> Name: ' + jd + '</p>'); }); }); }); </script> <h2>ABlog</h2> <p>Click on the button to load result.html file:</p> <div id="stage" style="background-color:blue;"> STAGE </div> <input type="button" id="driver" value="Load Data" />
WebAPI ->
public IEnumerable<Blog> GetBlogs() { return repository.GetAll();//.AsQueryable(); }
Any idea, how can I fix this error
Answers
-
User197322208 posted
for accessing a new site you required jsonp request, not json.
-
Marked as answer by
Thursday, October 7, 2021 12:00 AM
-
Marked as answer by
-
-
Marked as answer by
Anonymous
Thursday, October 7, 2021 12:00 AM
-
Marked as answer by