使用Ajax返回[重复]

This question already has answers here:
                </div>
            </div>
                    <div class="grid--cell mb0 mt4">
                        <a href="/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call" dir="ltr">How do I return the response from an asynchronous call?</a>
                            <span class="question-originals-answer-count">
                                (38 answers)
                            </span>
                    </div>
            <div class="grid--cell mb0 mt8">Closed <span title="2013-03-25 23:14:48Z" class="relativetime">7 years ago</span>.</div>
        </div>
    </aside>

I am trying to return a value with ajax for succes and fail but it only returns undefined. This is my script

function loginCheck(email, password, id){
    $.get("inc/ajax/login_check.php",
        {email:email, password:password},
        function(html){
            if(html == 0){
                return 0;
            }
            else{
                return 1;
            }
        }
    );
}
</div>

Please, please, please do not use GET as your method for user and passwords, security-wise it's a terrible idea.

That being said, to your question:
$.get is a shorthand for $ajax. Sometimes, it is a much better practice to declare the data's reference in your objects, that way you make sure it is being sent correctly. Try using $ajax with the full correct syntax, that goes like this:

$.ajax({
url: url,
data: data,
success: success,
dataType: dataType
});

Example:

$.ajax({
type: "POST",
url: "some.php",
data: { name: "John", location: "Boston" }
}).success(function( msg ) {
alert( "Data Saved: " + msg );
});

Full documentation: http://api.jquery.com/jQuery.ajax/