Sjoerd Andringa wrote:
> I dont know of a commonly used pattern for this, all of your suggestions 
> seem okay. Of course you don't need to parse xml and then update an 
> element, in a lot of situations just returning an html fragment and 
> update some element directly will suffice. In an application I developed 
> recently, which excessively uses the ExtJs framework, I use JSON 
> responses like Frederick suggests. (Be aware of Javascript Hijacking if 
> you use JSON for exchanging data, though it's not neccesarily a problem 
> when it only contains error messages.)

To make this a little more tangible; this is similar to my approach:

rescue_from Exception do |e|
  respond_to do |format|
    #...handle different formats
    format.js { render :json => {:error => e.to_s}.to_json, :status => 
500 }
  end
end

Then in my Ajax callback method when a 500 is returned I know there's an 
'error' property on the returned JSON object, of which the value can 
then be inserted into an element, or whatever else you want to do with 
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to