i''ve been trying my hardest to work out why the following doesn''t work on safari but works well with FF and the evil IE.. new Ajax.Request(''/include/dynamic.php?Login'', { method: ''get'', requestHeaders: {Accept: ''application/json''}, evalScripts: true, onSuccess: function(transport, json){ if (json.length>0 && json.length!=undefined) { for (var i=0; i<json.length; i++) { objHolder.push([json[i].name, json[i].node, json[i].replacement]) } } else if (json.length == undefined && json.name != undefined) { objHolder.push([json.name, json.node, json.replacement]) } } }); which calls the dynamic.php for its login scripts that returns: HTTP/1.0 200 OK Connection: close X-Powered-By: PHP/5.2.1 Content-type: application/json X-JSON: [{"name":"recover","node":"login","replacement":"<form method\"post\" name=\"recover\" action=\"\" onsubmit=\"do_recover(this); return false; \">\ t<fieldset title=\"Recover your password\"><legend>Recover your password<\/legend><label>Login:<\/label><input t ype=\"text\" id=\"Login\" onchange=\"return modify(this);\" alt=\"Login \" tabin dex=\"1\" \/><br \/><label>Email:<\/label><input type=\"text\" id=\"Email\" onchange=\"return modify(this);\" alt\"Email\" tabi ndex=\"2\" \/><br \/> <input type=\"button\" class=\"cancel button\" id=\"Cancel\" onclick=\"dyn_feature(''login''); return false; \" value=\ "Cancel\" tabindex=\"4\" \/><input type=\"submit\" class=\"recover bu tton\" id=\"Recover\" value=\"Recovery\" tabindex=\"3\" \/><\/ fieldset> <\/form>"},{"name":"login","node":"login","replacement":"<form method\"post\" name=\"login\" action=\"\" onsubmit=\"do_login(this); return false;\"> \ t<fieldset title=\"Login\"><legend>Login to AMHE<\/legend>\ r<label>Login:<\/label><input type=\"text\" id=\"Login\" onch ange=\"return modify(this);\" alt=\"Login\" tabindex=\"1\" \/><br \/> <label>Passphrase:<\/label><input type=\"password\" id=\"Pa ssphrase\" onchange=\"return modify(this);\" alt=\"Password\" tabindex\"2\" \/><br \/><input type=\"button\" class=\"recovery button\" id=\"Recover\" onclick=\"dyn_feature(''recover''); return false;\" value\"Recovery \" tabindex=\"4\" \/><input type=\"submit\" class=\"okay button\" id\"Okay\" value=\"Okay\" tabindex=\"3\" \/><\/fieldset><\/form>"}] Date: Thu, 26 Apr 2007 08:51:45 GMT Server: lighttpd/1.4.13 under Firefox/ie it loads these two functions but not under safari, and when i try to output json with alert(json) i get nothing, can anyone lend me an extra set of eyes on this one please? my guess is on the function(transport, json){..} side of it since none of the docs reference calling it like this but its the only way it works under IE/ FF Paul --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You''d be safer outputting your JSON in the responseText rather than in a header. Regards, Tobie On Apr 26, 4:55 am, nihaopaul <nihaop...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i''ve been trying my hardest to work out why the following doesn''t work > on safari but works well with FF and the evil IE.. > > new Ajax.Request(''/include/dynamic.php?Login'', { > method: ''get'', > requestHeaders: {Accept: ''application/json''}, > evalScripts: true, > onSuccess: function(transport, json){ > if (json.length>0 && json.length!=undefined) { > for (var i=0; i<json.length; i++) { > objHolder.push([json[i].name, json[i].node, json[i].replacement]) > } > } else if (json.length == undefined && json.name != undefined) { > objHolder.push([json.name, json.node, json.replacement]) > } > } > > }); > > which calls the dynamic.php for its login scripts that returns: > > HTTP/1.0 200 OK > Connection: close > X-Powered-By: PHP/5.2.1 > Content-type: application/json > X-JSON: [{"name":"recover","node":"login","replacement":"<form method> \"post\" > name=\"recover\" action=\"\" onsubmit=\"do_recover(this); return false; > \">\ > t<fieldset title=\"Recover your password\"><legend>Recover your > password<\/legend><label>Login:<\/label><input t > ype=\"text\" id=\"Login\" onchange=\"return modify(this);\" alt=\"Login > \" tabin > dex=\"1\" \/><br \/><label>Email:<\/label><input > type=\"text\" id=\"Email\" onchange=\"return modify(this);\" alt> \"Email\" tabi > ndex=\"2\" \/><br \/> <input type=\"button\" class=\"cancel > button\" id=\"Cancel\" onclick=\"dyn_feature(''login''); return false; > \" value=\ > "Cancel\" tabindex=\"4\" \/><input type=\"submit\" class=\"recover bu > tton\" id=\"Recover\" value=\"Recovery\" tabindex=\"3\" \/><\/ > fieldset> > <\/form>"},{"name":"login","node":"login","replacement":"<form method> \"post\" > name=\"login\" action=\"\" onsubmit=\"do_login(this); return false;\"> > \ > t<fieldset title=\"Login\"><legend>Login to AMHE<\/legend>\ > r<label>Login:<\/label><input type=\"text\" id=\"Login\" onch > ange=\"return modify(this);\" alt=\"Login\" tabindex=\"1\" \/><br \/> > <label>Passphrase:<\/label><input type=\"password\" id=\"Pa > ssphrase\" onchange=\"return modify(this);\" alt=\"Password\" tabindex> \"2\" \/><br \/><input type=\"button\" class=\"recovery button\" id > > =\"Recover\" onclick=\"dyn_feature(''recover''); return false;\" value> \"Recovery > \" tabindex=\"4\" \/><input type=\"submit\" class=\"okay button\" id> \"Okay\" value=\"Okay\" tabindex=\"3\" \/><\/fieldset><\/form>"}] > Date: Thu, 26 Apr 2007 08:51:45 GMT > Server: lighttpd/1.4.13 > > under Firefox/ie it loads these two functions but not under safari, > and when i try to output json with alert(json) i get nothing, can > anyone lend me an extra set of eyes on this one please? my guess is on > the function(transport, json){..} side of it since none of the docs > reference calling it like this but its the only way it works under IE/ > FF > > Paul--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
nihaopaul
2007-Apr-27 08:04 UTC
Re: SAFARI 2.0.4 and version 1.5.1_rc3 prototype using JSON
On Apr 27, 2:21 am, tobie <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You''d be safer outputting your JSON in the responseText rather than in > a header.Tobie, my new best friend! worked like a charm in safari and just took one line in the js function: new Ajax.Request(''/include/dynamic.php?Login'', { method: ''get'', requestHeaders: {Accept: ''application/json''}, evalScripts: true, onSuccess: function(transport, json){ //Tobie rocks for this next line for safari support json = json || transport.responseText.evalJSON(); if (json.length>0 && json.length!=undefined) { for (var i=0; i<json.length; i++) { objHolder.push([json[i].name, json[i].node, json[i].replacement]) } } else if (json.length == undefined && json.name != undefined) { objHolder.push([json.name, json.node, json.replacement]) } } }); also i printed the content instead of including it in the header: //php class function private function output($array) { $output = json_encode( $array ); header(''Content-type: application/json''); print($output); } paul --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Richard Quadling
2007-Apr-27 10:43 UTC
Re: SAFARI 2.0.4 and version 1.5.1_rc3 prototype using JSON
On 27/04/07, nihaopaul <nihaopaul-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Apr 27, 2:21 am, tobie <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > You''d be safer outputting your JSON in the responseText rather than in > > a header. > > > Tobie, my new best friend! > > worked like a charm in safari and just took one line in the js > function: > > new Ajax.Request(''/include/dynamic.php?Login'', { > method: ''get'', > requestHeaders: {Accept: ''application/json''}, > evalScripts: true, > onSuccess: function(transport, json){ > //Tobie rocks for this next line for safari support > json = json || transport.responseText.evalJSON(); > if (json.length>0 && json.length!=undefined) { > for (var i=0; i<json.length; i++) { > objHolder.push([json[i].name, json[i].node, > json[i].replacement]) > } > } else if (json.length == undefined && json.name != undefined) { > objHolder.push([json.name, json.node, json.replacement]) > } > } > }); > > also i printed the content instead of including it in the header: > //php class function > private function output($array) { > $output = json_encode( $array ); > header(''Content-type: application/json''); > print($output); > }private function output($array) { header(''Content-type: application/json''); echo json_encode( $array ); } Same but different.> > paul > > > > >-- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Michael Peters
2007-Apr-27 13:53 UTC
Re: SAFARI 2.0.4 and version 1.5.1_rc3 prototype using JSON
nihaopaul wrote:> On Apr 27, 2:21 am, tobie <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> You''d be safer outputting your JSON in the responseText rather than in >> a header. > > > Tobie, my new best friend!While some cases require putting the JSON in the body instead of headers since browsers do limit the sizes of headers they accept (anyone know where these limits are documented for each browser?), I will point out that you don''t have to. In your case safari has an issue where it won''t process the headers if there''s no body content in the response. So simply adding an empty newline char or something similar would have made your original problem work. -- Michael Peters Developer Plus Three, LP --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---