I''m trying to use jQuery to write all my js unobtrusively, and running into a bit of a problem when triggering the format.js block in IE6 (and possibly IE7). It returns the JSON string no problem, but instead of parsing it, IE6 asks to download the resource as a .js file. So if my url is ''/pictures/1.js'', IE6 will ask to save or run ''1.js'' I did do some digging, and I understand that IE sets */* on the Accept header. I''m not sure if it has to do with that or not. It is triggering the format I''m asking for. It''s just that IE6 won''t recognize it as a typical javascript response. Here''s some code. Also note that this is for an image upload, so it''s not a real AJAX request, and I''m using the jQuery Form plugin to post to an iframe. The details of my ajax call: var options = { url: /pictures/1.js, iframe: true, beforeSubmit: prepImageArea, success: imageUploaded, dataType: ''script'', beforeSend: function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} } And my respond_to block: respond_to do |format| format.html { redirect_to edit_picture_path(@picture) } format.js { render :json => @picture.to_json(:methods => [:public_filename, :large_thumb]) } end Any suggestions? Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Fri, 2008-09-26 at 01:38 +0200, Bryan M. wrote:> I''m trying to use jQuery to write all my js unobtrusively, and running > into a bit of a problem when triggering the format.js block in IE6 (and > possibly IE7). It returns the JSON string no problem, but instead of > parsing it, IE6 asks to download the resource as a .js file. > > So if my url is ''/pictures/1.js'', IE6 will ask to save or run ''1.js''did you try relaying on the request type per se, without the .js on the url?> > I did do some digging, and I understand that IE sets */* on the Accept > header. I''m not sure if it has to do with that or not. It is triggering > the format I''m asking for. It''s just that IE6 won''t recognize it as a > typical javascript response. > > Here''s some code. Also note that this is for an image upload, so it''s > not a real AJAX request, and I''m using the jQuery Form plugin to post to > an iframe. > > The details of my ajax call: > > var options = { > url: /pictures/1.js, > iframe: true, > beforeSubmit: prepImageArea, > success: imageUploaded, > dataType: ''script'', > beforeSend: function(xhr) {xhr.setRequestHeader("Accept", > "text/javascript")} > } > > And my respond_to block: > > respond_to do |format| > format.html { redirect_to edit_picture_path(@picture) } > format.js { render :json => @picture.to_json(:methods => > [:public_filename, :large_thumb]) } > end > > Any suggestions? Thanks.--
> did you try relaying on the request type per se, > without the .js on the url?Taking the .js off the url just triggers the html response. I can append the url with the query string /?format=js (as if i had written "link_to resource_path(@resource), :format => js") but I run into the same problem. Instead of asking to download/run a file called "resource.js" it just asks to download/run a file called "resource." This does make me thing it''s a header problem with IE, but I''m still pretty confused about it. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Seemingly Similar Threads
- Rails and JQuery and Ajax/Json question
- Rails 3.2 jQuery JSONP request not working - Moved Permanently
- HowTo; Rails 3, having Tabs that load content via jQuery ... No Page Refesh
- jQuery & unobstrusive javascript
- CRUD model in a bootstrap modal with jquery, ajax - best practice