Added some error checking for update method
Altered AJAX request to send post data to update method