I would suggest using this in your PHP script: header( "Last-Modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" ); header( "Expires: " . gmdate( "D, j M Y H:i:s", time() ) . " GMT" ); header( "Cache-Control: no-store, no-cache, must-revalidate" ); // HTTP/1.1 header( "Cache-Control: post-check=0, pre-check=0", FALSE ); header( "Pragma: no-cache" ); // HTTP/1.0 header('X-JSON:('.$json.')');
where $json is your JSON. Now Prototype will automatically eval your JSON onSuccess: function(transport.response) { alert(response.from_firstName.isEmpty); } will pop up an alert box stating "Value is empty, but a non-empty value is required". The ouput from your PHP script is not returning an array. I think you might be looking to return something like: {arUsers:[{fname:'Joe', lname:'User', email:'[EMAIL PROTECTED]'}, {fname:'Jane', lname:'Doe', email:'[EMAIL PROTECTED]'}]} Now you could use each to iterate over the elements you will find in response.arUsers. response.arUsers.each(function(s) { // do stuff like sign them up for spam } HTH Happy Prototyping Bernie On Apr 23, 6:29 pm, Luke The Duke <[EMAIL PROTECTED]> wrote: > Hi all > > Iam new to Prototype and I have the following question: > > A PHP Script (Zend Framwork) returns the following JSON Code after > submitting a Form: > > {"from_firstName":{"isEmpty":"Value is empty, but a non-empty value is > required"},"from_lastName":{"isEmpty":"Value is empty, but a non-empty > value is required"},"from_email":{"isEmpty":"Value is empty, but a non- > empty value is required"},"to_firstName":{"isEmpty":"Value is empty, > but a non-empty value is required"},"to_lastName":{"isEmpty":"Value is > empty, but a non-empty value is required"},"to_email": > {"isEmpty":"Value is empty, but a non-empty value is required"}} > > Now the idea is to draw a red border around all the formfields > mentioned in the JSON Code like 'from_firstName', 'from_lastName' etc. > > So i thought I could proceed the data with evalJSON() to an object and > than use the each() method. I tried the following code: > > handleJSONResponse:function(transport) { > var data = transport.responseText.evalJSON(true); > data.each(function(s) { > alert(s); > }); > > } > > but nothing happens.. no error, nothing. I can > alert(transport.responseText) which returns me the JSON Code above. > But each() doesnt return me anything. > > What do I do wrong? > > Thanks for your help! > > Luke The Duke --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---