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..
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.
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.
Comments