Skip to Content
Menu
This question has been flagged
1 Reply
1975 Views

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
Discard
Best Answer

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

Avatar
Discard
Related Posts Replies Views Activity
3
Oct 23
5981
1
Sep 23
1973
1
May 23
1007
2
Apr 23
1379
1
Mar 23
997