Javascript and jquery I can't read value from array index

97
May 31, 2021, at 5:40 PM

I have a list of numbers (ex."20,145") that returns from an ajax call and I am pushing them to a js array. After reading the first index of list console.log(list[0]) I got undefinied on console screen. I need to use them inside DOMContentloaded function.

<script>
            var list = [] //my empty list
            for (var i = 1; i < 13; i++)
            {
                checkMonth(i); //calling function 12 times because of the months count
            }
            function checkMonth(n)
            {
                $.ajax
                    ({
                        type: "POST",
                        url: "Homepage.aspx/BringDatas",
                        data: "{'month':'" + n + "'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "text",
                        success:
                            function (output) {
                                var sendedvalue = JSON.parse(output);
                                list.push(sendedvalue.d);//that returns numbers like "20,456"
                            },
                        error:
                            function () {
                            alert("hata var");
                        }
                    });
            }
document.addEventListener("DOMContentLoaded", function ()
            {
                // after getting all values I inserted list I can see on console screen and it works
                var person = [];
                person = list;
                console.log(list); // that works succesfull
                console.log(list[0]) // that is not working
Rent Charter Buses Company
READ ALSO
I want to filter the clients of every agent individually. Django

I want to filter the clients of every agent individually. Django

I'm creating a view where I can show all the clients of specific agents via there PK

188
Vue.js disable blank comments

Vue.js disable blank comments

Usually, when Vuejs hides an element through v-if, a comment is left in its place

128
How do I get the correct value in dataframe while webscraping?

How do I get the correct value in dataframe while webscraping?

I am trying to get value from websraping however, I am not able to construct correct class for the value

47
Delete Multiple DB rows and Images with Same title

Delete Multiple DB rows and Images with Same title

I am trying to delete multiple rows based on 'slug' column using CodeigniterForm DB all rows are deleted but the problem is with Images

107