First of all, why do you want to separate the file into chunks? You can upload the whole file in a go via AJAX. The error that you are encountering might be due to the chunk logic.
Try removing the chunk logic and it will work just fine. So your upload function would look something like this:
Instead of chunks, send the full file and it should work.
If you are worried about the upload progress, here are a few solutions:
jQuery Upload Progress and AJAX file upload ,
File upload progress bar with jquery
Its because I want this function to upload a large file. which, if not in the chunk, 32 bit server can't upload more then 2gb in total of data.