Javascript TypeError - Illegal invocation - undefined in chrome

Javascript TypeError - Illegal invocation - undefined in chrome
0

#1

Tell us what’s happening: when i debug in google chrome say: "javascript TypeError - Illegal invocation - undefined "
this is my code

function runScreenJson() {
    try {
        $.ajax({
            url: baseUrl + "/POPUP_DRUM_TEST/POPUP_DRUM_TEST_GET_DETAIL_Gets",
            type: 'GET',
            data: {
                POPUP_DRUM_TEST: _POPUP_DRUM_TEST
            },
            success: function (datajson) {
                try {
                    if (datajson != null && datajson != "") {
                        Navigator_Data(datajson);
                    }
                } catch (ex) {
                    console.log("ERROR (Navigator_Data): " + ex.name + " - " + ex.message + " - " + ex.description); //ex.message && ex.name
                }


                setTimeout("runScreenJson()", 1000);
            },
            error: function () {
                console.log("ERROR Request : " + baseUrl + "/POPUP_DRUM_TEST/POPUP_DRUM_TEST_GET_DETAIL_Gets"); //ex.message && ex.name
                setTimeout("runScreenJson()", 1000);
            }
        });
    } catch (ex) {
        console.log("ERROR (runScreenJson): " + ex.name + " - " + ex.message + " - " + ex.description); //ex.message && ex.name
        setTimeout("runScreenJson()", 1000); 
    } 
}

#2

By itself, this code does nothing. How are you calling this function? Where is the code which calls this function?

When I try hard-coding a call to the function, baseUrl is undefined, because you did not provide the code which has it.


#3

Hi @ randelldawson thanks u for the answer! this function i want get data from database to the views in my project
i want to know my syntax wrong where or misstake . This is all my script:

$(window).ready(function () {
    //changeStyleMachineBlock();
});

$(window).load(function () {
    //changeStyleMachineBlock();
    runScreenJson();
    
});


function runScreenJson() {
    try {
        $.ajax({
            url: baseUrl + "/POPUP_DRUM_TEST/POPUP_DRUM_TEST_GET_DETAIL_Gets",
            type: 'GET',
            data: {
                POPUP_DRUM_TEST: _POPUP_DRUM_TEST
            },
            success: function (datajson) {
                try {
                    if (datajson != null && datajson != "") {
                        Navigator_Data(datajson);
                    }
                } catch (ex) {
                    console.log("ERROR (Navigator_Data): " + ex.name + " - " + ex.message + " - " + ex.description); //ex.message && ex.name
                }


                setTimeout("runScreenJson()", 1000);
            },
            error: function () {
                console.log("ERROR Request : " + baseUrl + "/POPUP_DRUM_TEST/POPUP_DRUM_TEST_GET_DETAIL_Gets"); //ex.message && ex.name
                setTimeout("runScreenJson()", 1000);
            }
        });
    } catch (ex) {
        console.log("ERROR (runScreenJson): " + ex.name + " - " + ex.message + " - " + ex.description); //ex.message && ex.name
        setTimeout("runScreenJson()", 1000); 
    } 
}

function Navigator_Data(jdata) {

    var objItems = $("_POPUP_DRUM_TEST");

    for (var i = 0; i < jdata.length ; i++) {
        $("." + jdata[i].LINE + "_PROCESS strong").text(jdata[i].PROCESS);
        $("." + jdata[i].LINE + "_PROBLEM_1 strong").text(jdata[i].PROBLEM_1);
        $("." + jdata[i].LINE + "_PROBLEM_2 strong").text(jdata[i].PROBLEM_2);
        $("." + jdata[i].LINE + "_VEHICLE_INFOMATION_1 strong").text(jdata[i].VEHICLE_INFOMATION_1);
        $("." + jdata[i].LINE + "_VEHICLE_INFOMATION_2 strong").text(jdata[i].VEHICLE_INFOMATION_2);
        $("." + jdata[i].LINE + "_DENTAIL_PROBLEM_1 strong").text(jdata[i].DETAIL_PROBLEM_1);
        $("." + jdata[i].LINE + "_DENTAIL_PROBLEM_2 strong").text(jdata[i].DETAIL_PROBLEM_2);
        $("." + jdata[i].LINE + "_DENTAIL_PROBLEM_3 strong").text(jdata[i].DETAIL_PROBLEM_3);
        $("." + jdata[i].LINE + "_DENTAIL_PROBLEM_4 strong").text(jdata[i].DETAIL_PROBLEM_4);
        
    }

}

when i debug in google chrome tool my function stop this line :

catch (ex) {
        console.log("ERROR (runScreenJson): " + ex.name + " - " + ex.message + " - " + ex.description); //ex.message && ex.name
        setTimeout("runScreenJson()", 1000); 
    }

#4

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.