Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
1 Balas
2508 Tampilan

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
Buang
Jawaban Terbai

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

Avatar
Buang
Post Terkait Replies Tampilan Aktivitas
2
Okt 25
1809
3
Okt 23
10341
1
Sep 23
3860
1
Mei 23
2836
2
Apr 23
3557