Call Jquery and ajax between two different domain (cross-domain)

Hi

If You have to call one page index.htmlfrom http://domain1.com to http://domain2.com
then You have to add code given below in top of index.html file of http://domain1.com in the top

switch ($_SERVER['HTTP_ORIGIN']) {
case 'http://domain1.com': case 'https://domain1.com':
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Content-Type');
break;
}

and call jquery or ajax in page of http://domain2.com.

It will be allow to access to access via ajax/jquery cross domain.

thanks.