AJAX呼叫跨网域问题

I am trying to login to my wordpress site using ajax call, which i asked in previous question. It should not respond anything back. But whenever i call this ajax function, Firefox(firebug) is showing 200 OK in red. This must be a cross domain issue. Tried too many things but no luck so far. Here is the code:

$.ajax({
         type: "POST",
         url: "http://path-to-wordpress/wp-login.php",
         data:myData
         success: function(data){

         },
        error: function (xhr, ajaxOptions, thrownError) {

        }   
});

Any suggestion will be appreciated.

You need to add CORS headers in you wp-login.php page.

Here's how to do it

But given the nature of the page, be extra cautious : don't allow all origins (*) but only your site. If you allow all, your users could have their login info stolen.

Set the dataType to JSONP, in your ajax call and it will work cross-domain

For refrence ot ajax call visit jQuery Ajax

I assume your JS code is on abc.com and your wordpress site is dev.abc.com.

To fix cross domain issue, just add the following code to .htaccess file to your wordpress site (dev.abc.com)

SetEnvIf Origin "^http(s)?://(.+\.)?(abc\.com)$" origin_is=$0 
Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is

Just replace (abc\.com) with a proper site name. For eg: (google\.com) or (yahoo\.com)

There is property named crossDomain of $.ajax. Please set it to true.