Ajax请求失败为什么?

following my code:

    $('#btnOK').click(function(e){
        e.preventDefault();
        $form = $('#testForm');
        dataString = $form.serialize();
        $.ajax({
            type: "POST",
            url: 'https://abc.com/login',
            data: dataString,
            dataType: 'xml',
            success: function( returnData ) {
                alert(returnData);
            }
        });
    });

My Code fails to make ajax request to http://abc.com/login page and doesn't gives out result. What's the mistake here?

Is it due to cross domain likely:
my domain: http://xyz.com
login domain: http://abc.com/login

my domain: http://xyz.com login domain: http://abc.com/login

This is cross domain issue you can get over with

  1. Proxy on your site

  2. JsonP support from abc.com site

  3. If you just want to post and dont care what result is, you can create a form and a iframe then set target of the form to that iframe, then just post (wont work with csrf enabled site)

unless your abc.com domain is configured to deal with cross-origin policy, you won't be able to make a cross-domain ajax call

A solution is to redirect your ajax call to a server side proxy under xyz.com domain who send your data and get the response from abc.com (e.g. using CURL).

or if you're in control of abc.com domain you could send proper headers (Access-Control-*) to allow crossdomain calls

Just debug it use chrome or ie debugger, make a breakpoint at the entry of the click() function, and then step by step, you'll find the problem.