Не могу решить эту проблему уже несколько дней можете помочь?

function makeid(length) {
    let result      =  'dnr-';
    let characters  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    let charactersLength = characters.length;
    for (let i = 0 ; i<length; i++){
        result +=characters.charAt(Math.floor(Math.random()*charactersLength));
    }
    return result;
}
let orderNumber = makeid(8)
console.log(orderNumber)
function makeXHR(){
    let first = document.getElementById('amount').value,
     userName1 = document.getElementById('userName').value,
     password1 = document.getElementById('password').value,
     xhr = new XMLHttpRequest();
     xhr.onreadystatechange = function () {
        if(xhr.readyState == 4 && xhr.status == 200){
            document.getElementById('Result').innerHTML=xhr.responseText;

        }
    } 
    let Url = new URL('https://site.ru/payment/rest/register.do?orderNumber='+orderNumber+'&amount=123&currency=934&language=ru&password=ds81956H&returnUrl=https://site.ru/payment/finish.html%3Flogin%028161%26password%3DGbds81956H&userName=10028161&pageView=DESKTOP&description=orderDesc');
    let TOString = Url.toString()
    xhr.open('GET','TOString',true);
    xhr.send(null);
}
    <form>
    <label>summa</label><br>
    <input type="number" id="amount" name="amount1" value=""><br>
    <label>LOGIN</label><br>
    <input type="text" id="userName" name="userName1" value=""><br>
    <label>PASSWORD</label><br>
    <input type="password" id="password" name="password1" value=""><br>
</div>
<button type="submit" onclick="makeXHR()">отправить</button>
</form>
Вот ошибки Access to XMLHttpRequest at 'file:///C:/Users/com/Desktop/htmlPay/TOString' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.

Я хочу отправить запрос на регистрации на платежную систему , потом получить ответ , при клике на button отправить запрос на сервер но

index.js:26 GET file:///C:/Users/com/Desktop/htmlPay/TOString net::ERR_FAILED makeXHR @ index.js:26 // Это говорит xhr.send(null) не айдено onclick @ index.html:18 // Это говорит что makeXHR не найдено


Ответы (0 шт):