In “get_data” action ,there are some code like this:
def get_data
if params[:p]=='1'
raise "error 1"
elsif params[:p]=='2'
raise 'error 2'
else
return data
end
end
in view:
<script>
$.getJSON('/controller/get_data',function(){...})
</script>
so,when some error has raised,how can i get it!
Tks!
One thing to remember is.
getJson is just a thin wrapper for:
Which in turn is a thin wrapper for get:
Which simply boils down to a call to $.ajax, which has a simple failure and success handler.
So you could simply do: