views:

189

answers:

2

Hi, 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.

A: 

You should be able to view the ajax reponse in firebug and see what is gtting posted back to you - you can get a 200 error but still get an error in the post back. Don't you need to do something with an AuthToken too?

matpol
The response is empty :( I want the AuthToken to get photos from a picassaweb account, but I would simplify the problem. In fact, at the beginning I was using Prototype but I decide to do it without frameworks with the aim of understand the problem.
nin1987
just googled a bit - does the picasa api actually support javascript? I've only every used curl to do this.
matpol
A: 

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

nin1987