Code under the ajax request won't wait for the ajax request to be completed before it is being executed. So I think your ajax request is working, but nothing happens with the data because that piece of code was executed already.