$.ajax success and error

$.ajax success and error

Hi. I'm relatively new to jquery. I was trying to do the authentication using JSON API's and if its a success it should start holding the session. If the JSON api doesn't retrieve any results, it should pop an alert showing "Not a User

Here is the script. I'm not sure what is missing. Its able to display "success loop" message but not the error alert
  1. $.ajax
  2. ({ 
  3.             type: 'GET', 
  4.               url: link,
  5.             dataType: "jsonp", 
  6.             success: function (data) 
  7.            
  8.            
  9.             $.session("sessionVariable",username);
  10.             //alert($.session("sessionVariable"));
  11.                 alert("success loop");
  12.                
  13.            },
  14.            
  15.           error: function () {
  16.         alert("not a user. Unable to login")
  17.       }
  18.            
  19.         });