This works for me. The only difference that I can see is you are trying to input the dimensions via the AJAX object, where as I create and then set them directly into to the Array object.
Your way looks cooler and more advanced, but my way ... works? Let me know if you can figure it out, because I use this process quite often and would love to know a shortcut!