Hi All, Safari crashes everytime my ajax response is bigger than 10k, i traced it down and found out that it breaks when evalScript is being called, maining when extractScript is trying to match the regex..... is this a known bug on safari? if yes is there anyway to get around it? thanks in advance --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2007-Mar-01 08:10 UTC
Re: prototype ajax.updater response bigger than 10k on safari
yoshi a écrit :> is this a known bug on safari? > > if yes is there anyway to get around it?I ran into string length issues with regex''s on Firefox as well. As my regex was fairly simple, I ended up doing a manual global replacement, which certainly isn''t quite the golden road. I would be tempted to say you''re not quite supposed to send 10+K of data in an AJAX response; that''s not quite what AJAX was designed for, I mean, 10K feels like a whole, content-rich page, not a page fragment or JSON data! But then, Real Life Is Different, I''m sure you''ll say :-) In the end, though, your issue remains. Since Prototype runs stripScripts (not extractScripts or evalScripts, BTW) on your String, you do have a regex matching. It will occur both in evalScripts: true and evalScripts: false contexts (in Elt.update or A.U.updateContent, respectively). So you''re grilled. The only workaround I see out of my hat just now is, if you *don''t* have script blocks, use Ajax.Request and manually write to the target element''s innerHTML in your own onSuccess callback. Yewh, I know. -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
yup ideally the 10k response should be seperated in to chunks and make several requests, but the piece of code that generates the response is legacy code and touches many java files, so i m not comfortable changing that..... ok heres my 1st attack on this, and anyone thinks they have a better idea plz respond.... i m using ajax.updater currently, my ajax response returns only script text, contianing the script tag. Instead of setting ''evalScript: true'' in the method, i set onComplete: function(response) { //some element already loaded that i know is on the page var scriptTag = document.createElment(''script''); scriptTag.type = ''text/javascript''; scriptTag.text = response.responseText; $(''bodyContent'').appendChild( scriptTag ); } i think appendChild is the same as doing an eval() right guys? of course the above did not work, but theoritically it should right? thanks in advance --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
dkrysiak-h7QdYz1kt/Q@public.gmane.org
2007-Mar-02 21:46 UTC
Re: prototype ajax.updater response bigger than 10k on safari
On 1 Mar, 10:54, "yoshi" <yosh...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> > i m using ajax.updater currently, my ajax response returns only script > text, contianing the script tag. > Instead of setting ''evalScript: true'' in the method, i setIf U have only JavaScript code in the response it will be better if you don''t send it as a html but as a text/javascript or using X-JSON http header wich prototype will evaluate automatically. Read here more: http://www.prototypejs.org/learn/introduction-to-ajax search for: "Evaluating a JavaScript response".> onComplete: function(response) { > //some element already loaded that i know is on the page > > var scriptTag = document.createElment(''script''); > scriptTag.type = ''text/javascript''; > scriptTag.text = response.responseText; > > $(''bodyContent'').appendChild( scriptTag ); > } > > i think appendChild is the same as doing an eval() right guys? > > of course the above did not work, but theoritically it should right?I''''m not sure... But in Your case I would do: onComplete: function(response) { eval(response.responseText); } Nothing more :-) Greetings DK --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
dkrysiak-h7QdYz1kt/Q@public.gmane.org
2007-Mar-02 22:51 UTC
Re: prototype ajax.updater response bigger than 10k on safari
> onComplete: function(response) { > eval(response.responseText); > > }Sorry! I forgot. According to documentation (the link which I gave U just a moment before): "Sometimes the application is designed to send JavaScript code as a response. If the content type of the response matches the MIME type of JavaScript then this is true and Prototype will automatically eval() returned code. You don''t need to handle the response explicitly if you don''t need to." So You don''t even need to call eval() - Your JavaScript code will be evaluated/run automatically. All You need to do is: - to send http Content-type as for example ''text/javascript'', If You send Your Ajax response using PHP this would look like this: <?php header("Content-type: text/javascript"); echo ''/* javascript code goes here */''; ?> - or request with Ajax a file with ".js" extension (Apache will send ''text/javascript'' automatically) - or send X-JSON header. In PHP it woul look like this: <?php header("X-JSON: ''. ''/* javascript code goes here */''); ?> Greetings DK --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
by auto eval(), when content type is ''text/javascript'', do u mean i dont need to define ''onSuccess: blah blah''? so assuming i change the content type of the response header, ( i checked the response header in firebug ) and my ajax.request code looks like new Ajax.Request(src, { method:''get''} ); no callback function defined? it didnt work............ WebKit, works, which means that there should be a bug similar to mine filed already, maybe i should look at there closed bug list and track down a work around until the next version of safari is released......... lord when safari is 5% of the traffic u pay for every click counts............. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On 3 Mar, 02:24, "yoshi" <yosh...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> by auto eval(), when content type is ''text/javascript'', do u mean i > dont need to define ''onSuccess: blah blah''? > so assuming i change the content type of the response header, ( i > checked the response header in firebug ) and my ajax.request code > looks like > > new Ajax.Request(src, { method:''get''} ); > > no callback function defined? it didnt work............It should. Check if JS code returned is correct. Maybe OT but for example, I had such a problem today (that''s why i read this list now): I was returning JS code like that { //some object properties using JSON } And added onExeption callback in Ajax.Request construtor parameters. The JSON code returned wasn''t correct for Firefox (throwed an exception) - it expected the block of expressions (surrounded with curly braces {}) and in fact it was an object in JS object notation (surrounded with curly braces too). Surrounding (adding not replacing ofc) all the Ajax response code in ordinary braces () has solved the problem. Of course to get the JSON value I had to eval() it again, because inner mechanism doesn''t save nowhere/return no way the result of eval()''s :-( --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---