Ajax无法正常工作1 [关闭]

                <div class="grid--cell fl1 lh-lg">
                    <div class="grid--cell fl1 lh-lg">
                        It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and   cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened,   <a href="/help/reopen-questions">visit the help center</a>.

                    </div>
                </div>
            </div>
            <div class="grid--cell mb0 mt8">Closed <span title="2012-03-31 18:12:57Z" class="relativetime">8 years ago</span>.</div>
        </div>
    </aside>

I have this ajax code that does not seem to be working. The code will not acknowledge a successful result it just keeps giving the else statement. I ran the dologin.php and it successful returned 1 Thank You in advance.

             <script src="http://code.jquery.com/jquery-1.6.2.js" type="text/javascript"></script>  
            <script>
                var jq162 = jQuery.noConflict(true);
            </script>
            <script type="text/javascript">
            $(document).ready(function(){
                $("#submit").click(function(){
                    var Username = $("#Username").val();
                    var Password = $("#Password").val();

                    $.ajax({
                        type: "POST",
                        url: "dologin.php",
                        data: "Username=" + Username + "&Password=" + Password,
                        success: function(result){
                            if(result=='1'){
                            $(document.location = '/reward/home.php');
                            }
                            if(result=='2'){
                                $(".errors").html("Contact Administrator<br>Please provide the following error code.<br>Error Code:101");
                            }
                            if(result=='3'){
                                $(".errors").html("Invalid Password");
                            }
                            else{
                                $(".errors").html("Incorrect Credentials");
                            }
                        }
                    });
                return false;   
                });
            })(jq162);
            </script>
</div>

You get the else case because you aren't using an if/else chain. It is probably executing the correct statement for 1, but later sees : if result was 3 ? else... and since it isn't 3, you get the else. Use an if/else chain instead. Also, remove the $() around document.location = '/reward/home.php'

if(result=='1'){
   document.location = '/reward/home.php';
}
else if(result=='2'){
   $(".errors").html("Contact Administrator<br>Please provide the following error code.<br>Error Code:101");
}
else if(result=='3'){
   $(".errors").html("Invalid Password");
}
else{
   $(".errors").html("Incorrect Credentials");
}

This is done more cleanly with a switch:

switch (result) {
  case 1:
    document.location = '/reward/home.php';
    break;
  case 2:
    $(".errors").html("Contact Administrator<br>Please provide the following error code.<br>Error Code:101");
    break;
  case 3:
    $(".errors").html("Invalid Password");
    break;
  default:
    $(".errors").html("Incorrect Credentials");
}