code

NS_ERROR_FAILURE : Firefox에서 실패

starcafe 2023. 9. 10. 12:26
반응형

NS_ERROR_FAILURE : Firefox에서 실패

javascript의 XMLHtpRequest 개체를 사용하여 (같은 서버 또는 도메인 이름이 아닌) 다른 페이지로 요청을 보내고 있습니다. firefox에서 ns_error_failure 오류가 발생하지만, javascript는 Google Chrome에서 작동합니다. 온라인으로 검색한 후 firefox의 XSS 정책 때문인 것 같습니다.도메인 간 요청은 허용되지 않습니다.

이 문제를 해결하고 JS를 크롬과 파이어폭스 둘 다에서 실행할 수 있는 방법이 있습니까?


추가적인 세부사항이 필요하다고 느끼신다면 언제든지 요청해주세요!


여기 제가 사용하던 코드가 있습니다.

"use strict";

function showFixed(username)
{
    console.log("Entered script");

    var url = 'https://api-dev.bugzilla.mozilla.org/latest/bug'
        + '?quicksearch='
        + encodeURIComponent('FIXED @'+username);
    displayBug(url);
}

function showPending(username)
{
    console.log("Entered script");

    var url = 'https://api-dev.bugzilla.mozilla.org/latest/bug'
        + '?quicksearch='
        + encodeURIComponent('@'+username);
    displayBug(url);
}

function showCC(username)
{
    console.log("Entered script");

    var url = 'https://api-dev.bugzilla.mozilla.org/latest/bug'
        + '?quicksearch='
        + encodeURIComponent('cc:'+username);
    displayBug(url);
}

function displayBug(url)
{
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.open("GET",url,false);
    xmlhttp.send();
    var text = xmlhttp.responseText;

    var json = JSON.parse(text);

    for(var i=0;i<json.bugs.length;i++)
    {
        var tempRow = document.createElement('tr');

        var tempId = document.createElement('td');
        tempId.innerHTML = '<a href=\'https://bugzilla.mozilla.org/show_bug.cgi?id=' + json.bugs[i].id + '\'>'+ json.bugs[i].id + '</a>';
        var tempCreator = document.createElement('td');
        tempCreator.innerHTML = json.bugs[i].creator.real_name;
        var tempShortDesc = document.createElement('td');
        tempShortDesc.innerHTML = json.bugs[i].summary;
        var tempComponent = document.createElement('td');
        tempComponent.innerHTML = json.bugs[i].component;
        var tempAssignee = document.createElement('td');
        tempAssignee.innerHTML = json.bugs[i].assigned_to.real_name;
        var tempWhiteBoard = document.createElement('td');
        tempWhiteBoard.innerHTML = json.bugs[i].whiteboard;
        var tempBugStatus = document.createElement('td');
        tempBugStatus.innerHTML = json.bugs[i].status;
        var tempResolution = document.createElement('td');
        tempResolution.innerHTML = json.bugs[i].resolution;
        var tempLastChange = document.createElement('td');
        tempLastChange.innerHTML = json.bugs[i].last_change_time;

        tempRow.appendChild(tempId);
        tempRow.appendChild(tempAssignee);
        tempRow.appendChild(tempCreator);
        tempRow.appendChild(tempBugStatus);
        tempRow.appendChild(tempShortDesc);
        tempRow.appendChild(tempLastChange);
        document.getElementById('bugs-table-tbody').appendChild(tempRow);
    }

    document.getElementById('main').innerHTML = '';
}

function wrapper()
{
    var waitString = "Please wait while bug list is loaded..."
    document.getElementById('main').innerHTML = waitString;

jQuery를 사용할 수 있다면 JSONP(http://www.jquery4u.com/json/jsonp-examples/) 를 통해 크로스 도메인 아약스를 효과적으로 허용하는 것을 제안합니다.

언급URL : https://stackoverflow.com/questions/15442046/ns-error-failure-failure-in-firefox

반응형