How to check type of ajax response

Hello,
When my post message is successfully saved I am returning simple
message via:

flash[:notice] = “OK”

and when there are some errors due to validation I return the message
in similar way:

flash[:notice] = form.errors.to_xml()

then the message is sent via ajax:

respond_to do |format|
format.html { redirect_to :back }
format.js

How can I check on the client side which message was sent before
displaying it?
I am using jQuery.
Thanks,
bogumbiker