Search code examples
javascriptajaxxmlhttprequestpicasa

ClientLogin from Google API doesn't works with AJAX


I'm trying to login to a Google Account for request Picassa Web photos with AJAX. That's the code:

xmlhttp=new XMLHttpRequest();
xmlhttp.open("POST","https://www.google.com/accounts/Login",true);
xmlhttp.send("accountType=HOSTED_OR_GOOGLE&Email=...&Passwd=...&service=lh2&source=prova");
document.getElementById('prova').innerHTML=xmlhttp.responseText;

With this firebug shows a 200 OK status in the Net tab but an unexplained error in the Console. Of course nothing appears in the div called "prova" since answer is empty.

I also try to add this header:

xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");

But then firebug shows a 400 Bad Request in the Net tab. Can you help me? Thank you.


Solution

  • Solved! Firefox and new browsers don't let make AJAX call to third-party applications for security reasons. All is explained here: http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-harmful.html