First, you need to use "AJAX On Completed", or at least insert "Wait for previous action to complete" after AJAX request. Your array is empty because of that.
Tilemap has expressions MapDisplayWidth and MapDisplayHeight which return number of horizontal and vertical tiles.
And I don't understand why you are saving loopindex("x") and loopindex("y") in the array. If your array is the same size as the tilemap, then you can use its X/Y index for addressing.
Tilemap.TileAt(X, Y) - tile at X/Y
Array.at(X, Y) - value for that tile