How can I get the error messages ,when there is a error happened in $.getJSON

Posted by psjscs on Stack Overflow See other posts from Stack Overflow or by psjscs
Published on 2010-06-02T05:34:23Z Indexed on 2010/06/02 5:43 UTC
Read the original article Hit count: 141

Filed under:
|

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!

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about ruby-on-rails