I have a button in jsp like this.

```
 <input class="submit_button" type="submit" id="btnPay" name="btnPay" value="Payment"  
 style="position: absolute; left: 350px; top: 130px;" onclick="javascript:payment();">

```

The javascript function calls the java servlet and the servlet calls the function "callprocedure()" when the button is clicked. 

```
 <script>

     function payment()
    {

        var req = $.ajax({
        type: "POST",
        url: '/context/Servlet',
        success: function(result){
         //when successfully return from your java 
        alert('Payment done successfully...');
        }
        }, error: function(){
           // when got error             
           alert("sorry payment failed");            
        }
    });

    }      
</script> 

```

Now all works fine but my problem is to check the success or error in ajax. How can i check the success or error in ajax in my case.

Thanx in advance ...