ajax success return value complicated

Selvan Kumar

I am working some corrections in one website,I am stuck in ajax success value I couldn't understand the return method can you explain it..

    success:function(e)
        {   
          return""!=e?
          ($("#emailid").parent().addClass("error"),
          $("#email").parent().removeClass("success"),
          alert(e),
          $("#buttoncss").attr("disabled","disabled"),!1):void $("#buttoncss").removeAttr("disabled")}}

can you guys how return""!=e is working want to know return"" what is that..

Scott

In the example you provided, the check is to ensure that some data has been returned upon successful completion of the AJAX request. "" != e evaluates to either true or false depending on if any data has been returned. What this is checking is that e, the data returned from the AJAX request, actually contains anything.

Ternary operator

This works just like an if else statement block.

if (foo > bar)
    return true;
else
    return false

Can be rewritten as

return foo > bar ? true : false;

After "" != e has been evaluated to true or false, the ternary operator is used just like above. Statements proceeding the ? occur if the starter statement is true and statements proceeding the : occur if the starter statement is false. In other words, it could be rewritten as:

if("" != e){
   $("#emailid").parent().addClass("error"),
   $("#email").parent().removeClass("success"),
   alert(e),
   $("#buttoncss").attr("disabled","disabled"),!1);
   return true;
}

else{
    $("#buttoncss").removeAttr("disabled");
    return false;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

return value from ajax success function

From Dev

undefined return ajax success

From Dev

mvc ajax return partial view with model get the value of model in the success

From Dev

jQuery ajax return success data

From Dev

jQuery ajax return success data

From Dev

How to Return ajax result in success?

From Dev

PHP AJAX success value empty

From Dev

Return '0' or 0 on success from AJAX call?

From Java

jQuery: Return data after ajax call success

From Dev

How to return data from ajax success function?

From Dev

Simple success/error return with ajax and php

From Dev

Return values from arraylist to an ajax success function

From Dev

Ajax - success return more than 1 variable

From Dev

Return two variables in ajax success function

From Dev

jQuery AJAX return the function as data upon success

From Dev

Ajax call doesn't return success

From Dev

ajax success function return view on second click

From Dev

Return two variables in ajax success function

From Dev

AJAX - return JS Array and use it in success event

From Dev

Ajax call doesn't return success

From Dev

Ajax - success return more than 1 variable

From Dev

Ajax call function on success return false not working

From Dev

Ajax can success() handle two type of return?

From Dev

return a variable from ajax and php on success

From Dev

How do I return a selected value from a complicated dropdownlist in MVC?

From Dev

WINAPI methods with nonzero return value at success

From Dev

Determine method success when the return value is not a boolean

From Dev

Passing value from click (this) into ajax success in jQuery

From Dev

Updating a cell value after each ajax success

Related Related

HotTag

Archive