Ok, a 500 response means there is something wrong with your code rather than a permissions error.
Try switching off the "friendly HTTP error" in IE (if thats what you're using): Tools > Internet Options > Advanced then uncheck the box that says "Show friendly HTTP error messages"... then you should be able to see what the actual error that your script flags up.