简体   繁体   中英

Issue with jQuery ajax post

This is a followup to this question . Since the problem that I'm now facing is different from that, I thought I'll pose a new question.

I'm having an issue with the following code where in, the request is getting POSTed to the server, but whatever response the server has sent is not visible on the browser (in the form of an alert here).

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script>
$(document).ready(function() {
    $('#login').delegate('input#submit','click',function(){
        var request = $.ajax({
            type: "POST",
            url: "login",
            data: {userid: $("#userid").val(), password:$("#password").val()},
            datatype: "xml",
            cache: false,
            success: function(xml){alert(xml);}
        });
    });
});

</script>

I can see that this request is going to the server - can see it in the logs. But I don't see the server's response in the browser. Here's the server's response:

<result><url>landing-page</url></result>

Not sure what am I doing wrong, but this seems to be simple stuff that I should get it working without issue. Tried Firebug, but no luck. Any idea as to where am I going wrong here or on how to debug this issue further.

Thanks

Either change your "success" callback to a "complete" callback, or add a complete callback. My guess is that it isn't detecting a "success" even though the response is being successfully retrieved. If it fires the "complete" callback, then you can try and fix your webservice to provide a successful response.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM