Similar issue: ajax working fine until I tried to upload. I found out that (a) most browser clients don't know what to do with header application/json (b) the solution text/javascript is mixed up for some reason extra tags get added on which confuses the parsing (c) try setting your header as text/html that's what worked for me
Sorry, I can't give you concrete details about what's going on. Still an ajax-n00b. Chris Roos-3 wrote: > > > Morning, > > I have a simple file upload form. It works exactly as expected > without javascript. It *almost* works as expected when I convert it > to an ajax form, with something like form.ajaxSubmit(options). My > options contain a dataType definition, {'dataType' : 'json'}. I > believe that this directly relates to the HTTP Accept header and lets > my server know the type of data that I'm expecting to get back. If I > don't select a file to upload and hit submit then the Accept header is > populated correctly ("application/json, text/javascript, */*"). If I > do select a file to upload and hit submit then the Accept header > ignores my dataType and appears to default to the browser default > (something like "text/html,application/xhtml+xml,application/ > xml;q=0.9,*/*;q=0.8"). In practice, this means that although the file > is uploaded correctly, I'm unable to determine the the type of > response required from the server (in Rails I can't use respond_to to > detect a request for a js response). I'm wondering whether this is by > design or whether something's wrong here. > > Does anyone have any thoughts? > > Cheers, > > Chris > > -- View this message in context: http://old.nabble.com/Multipart-forms%2C-file-uploads-and-the-accept-header-tp22371165s27240p26638195.html Sent from the jQuery General Discussion mailing list archive at Nabble.com.