Skip to Content
Menu
This question has been flagged
1 Atsakyti
2470 Rodiniai

Hi all. Im getting error in web push notification module. Im trying to send notification but it gives error "Uncaught ReferenceError: XMLHttpRequest is not defined" in service.worker.js.  Here is my code:

function ajax_get(urlcallback) {
    // var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            console.log('responseText:' + xmlhttp.responseText);
            try {
                var data = JSON.parse(xmlhttp.responseText);
            } catch(err) {
                console.log(err.message + " in " + xmlhttp.responseText);
                return;
            }
            callback(data);
        }
    };
Portretas
Atmesti
Best Answer

var ajax = require('web.ajax'); at the begin program

Portretas
Atmesti
Related Posts Replies Rodiniai Veikla
2
spal. 25
1772
3
spal. 23
10266
1
rugs. 23
3839
1
geg. 23
2813
2
bal. 23
3528