Has anyone had any success using the Google Cloud Print (specifically the /search) API from JavaScript?
I have tried any number of ways but keep getting the following error.
XMLHttpRequest cannot load https://www.google.com/cloudprint/search. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
Code snippet:
var search = new XMLHttpRequest();
search.open('POST', 'https://www.google.com/cloudprint/search', true);
search.withCredentials = true;
search.setRequestHeader("X-Cloud-Print", "Google-JS");
search.onreadystatechange = function(response){
console.log(response);
};
search.send();
I am able to use the demo form post:
<form action="https://www.google.com/cloudprint/search" method="post" enctype="multipart/form-data" id="submitForm">
<input type="submit" value="Search"/>
</form>
from exactly the same webpage and it is successful; i have spent quite some time making sure that the two requests look identical in terms of submitted data and headers but to no avail. I am reluctant to have to write this in Java (as trying to avoid server backend involvement) and would welcome any help.
Origin is therefore not allowed access. from browser
Anyone know solution? – Disburse