I have integrated the third party API for validating a correct email address with the domain. The API call is returning the value in the ajax call as Boolean.

How to retrieve the value from the API response in ajax?

  • Please share your JS code. – kunj May 16 '18 at 11:38

The correct way to handle ajax requests with jquery is:

var jqxhr = $.ajax( "example.php" )
  .done(function( serverResponse) {
    alert( "success" );
  .fail(function() {
    alert( "error" );
  .always(function() {
    alert( "complete" );

The done function will be called if request is successfull, and serverResponse variable contains the returned values from your server.

See: http://api.jquery.com/jquery.ajax/

| improve this answer | |
  • We can get the value in alert and not able to pass it to another function. I need to retrieve the value and based on that need to display error message – Kavitha mano May 17 '18 at 5:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.