Reformatted code. Fixed AJAX to work with Arrays.