Using google spell check in my rails application

I am using the google spell check in my rails application, I am getting an empty response with the below error:

XMLHttpRequest cannot load http://www.google.com/tbproxy/spell?lang=en. Origin http://mysite.com is not allowed by Access-Control-Allow-Origin.

Can you please suggest what I can change.

This is the code in my javascript:

function makeRequest(parameters, svalue) {
    http_request.onreadystatechange = GetResponse;
    http_request.open('POST', 'http://www.google.com/tbproxy/spell?lang=en', true);

    data = '<?xml version="1.0" encoding="utf-8" ?>';
    data +='<spellrequest textalreadyclipped="0" ignoredups="0" ignoredigits="0" ignoreallcaps="0"><text>';
    data += 'hello this is a graet lsit of games';
    data += '</text></spellrequest>';

    http_request.send(data);
}

function GetResponse(){
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            http_response = http_request.responseText;
            // Some Code
        }
    }
    else {
        console.log('There was a problem with the request' + '& http_request.status =' + http_request.status );
        loaderDiv.style.display = 'none';
         }
    }
}

I added the below code in my app/application_controller.rb, but it did not help:

before_filter :allow_cross_domain_access

def allow_cross_domain_access
  response.headers['Access-Control-Allow-Origin']    = '*'
  response.headers['Access-Control-Request-Method']  = '*'
end

Please let me know if you require more information from me. Thanks.

newest questions tagged jquery – Stack Overflow

About Admin