Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to do AJAX cross domain calls ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 253
    Comment on it

    I was facing issue to post data by a form to foreign domain. I am aware of "AJAX cross-domain policy". So we just can't call "" over ajax http request and display the results on my page. So after researching I found following:

    i) To enable cross domain POST you have to enable 'Cross-Origin Resource Sharing' on both servers.

    ii) Another easy way is to get cross-domain data using AJAX is to use a server side language as the proxy. Here's a small sample how to implement that using jQuery:




        url: 'proxy.php',
        type: 'POST',
        data: {
            address: ''
        success: function(response) {
            // response now contains full HTML of

    PHP (proxy.php):


    echo file_get_contents($_POST['address']);

    Thanks for reading the blog

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: