dataList is an array. You can read the items from the array by iterating over the indexes of the array as in:
for (var i = 0; i < dataList.length; i++) {
// do something with dataList[i]
}
You can read just the last item in the array:
var item = dataList[dataList.length - 1];
// do something with item here
Or, if you just want to remove and retrieve the last from the array, you can do this:
var item = dataList.pop();
// do something with item here
MDN documentation for .pop() here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop. It's basically the opposite of .push().
There are a zillion other operations you can carry out on an array and they are all listed here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
In your specific code example where you are doing an ajax call, you also need to understand that most ajax calls are asynchronous. That means they finish some time in the future. As such, you can't just call the ajax call and then immediately examine dataList. Instead, you need to put any code that needs to reference dataList in the success handler for the ajax call or you need to call that code from the success handler and then pass dataList to it. This is how asynchronous programming works in javascript.
dataListholds data before doingpop()operation. FYI: pop() returns the last elements within the dataList.getListDatais called after the Ajax call succeeded. Have a look at stackoverflow.com/questions/14220321/….