Skip to Content
मेन्यू
This question has been flagged
1 Reply
2504 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
2
अक्तू॰ 25
1797
3
अक्तू॰ 23
10309
1
सित॰ 23
3854
1
मई 23
2828
2
अप्रैल 23
3549