How I kicked Cross Origin Resource Sharing’s Ass!

Just this past week I was working on a project that required me to write an uploader script. Nothing new or revolutionary here. There was, however, one major fly in the ointment – the upload handling script was being hosted on a different domain to script that was submitting the upload request! This was causing the upload to fail, with NO obvious error messages and no feedback what so ever. All I got back, was a failed message and no reason why.