I kept receiving a 406 error code when trying to use ajax in a rails app. The problem was that in the request’s Accept header, text/javascript wasn’t included, and this caused the error.
Additionally, I think this may have had something to do with it:
- I was submitting a form when on a select’s onChange handler, by using:
this.form.submit();
I changed it to :
$("#myform").submit();
I’m not really sure if this influenced it in someway, but I said, if I’m still using jQuery to do things, better use it to do everything.