Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
2468 Vistas

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);
        }
    };
Avatar
Descartar
Mejor respuesta

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

Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
oct 25
1769
3
oct 23
10244
1
sept 23
3836
1
may 23
2812
2
abr 23
3522