19
Mar
11

rails 406 error code when using ajax



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.

Advertisements

1 Response to “rails 406 error code when using ajax”


  1. 1 Jasminka
    October 16, 2012 at 23:25

    You saved my day with the jQuery submit change.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Blog Stats

  • 223,857 hits

%d bloggers like this: