jQuery ajaxForm returning .json file

Posted by Lowgain on Stack Overflow See other posts from Stack Overflow or by Lowgain
Published on 2010-05-03T02:08:37Z Indexed on 2010/05/03 2:18 UTC
Read the original article Hit count: 448

Filed under:
|
|
|

I've got a model creation form in rails which I also have returning JSON through ajax. My code so far look like:

$('#new_stem').ajaxForm({ //#new_stem is my form
  dataType: 'json',
  success: formSuccess
});

function formSuccess(stemObj) {
  //does stuff with stemObj
}

And I have a multipart form with a file uploader (but I'm not sure if that is relevant).

When I submit the form it works fine (my models are properly being created and renders as json), but instead of the json getting handled by the formSuccess function, it prompts a download for "stems.json" (the path to my stem creation action) in Firefox.

What would cause this to happen, and what could solve it? Not sure if this is part of the problem, but I don't have a submit button in my form, I have a link with a click handler that calls $('#new_stem).submit()

Thanks guys!

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about ajaxform