2

I am trying to post an image to picasa using javascript. I have got the required tokens. But when I post, I get an error "204 no content"

Here is my code.

function send() { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { if(xhr.readyState == 4) alert(xhr.status); } xhr.open("POST","https://picasaweb.google.com/data/feed/api/user/default/albumid/default", true); var type = document.getElementById('file').files[0].type; xhr.setRequestHeader('Accept','message/x-jl-formresult'); xhr.setRequestHeader("content-type",type); xhr.setRequestHeader('Content-Length',document.getElementById('file').files[0].size); xhr.sendAsBinary(document.getElementById('file').files[0].getAsBinary()); } 
7
  • 1
    If you are trying to do that request from an other domain than picasaweb.google.com the Same Origin Policy will block you. Commented Aug 25, 2011 at 16:44
  • But he gets a 204 response so that can't be the problem? Commented Aug 25, 2011 at 16:45
  • Just to nitpick: "204 No Content" is not an error. The 2xx class is for success codes. To quote the RFC, 204 means "The server has fulfilled the request but does not need to return an entity-body, and might want to return updated metainformation. The response MAY include new or updated metainformation in the form of entity-headers, which if present SHOULD be associated with the requested variant." w3.org/Protocols/rfc2616/rfc2616-sec10.html Commented Aug 25, 2011 at 16:46
  • @mcb Some browser do use the 204 header result when you are making a cross-domain XHR request. Commented Aug 25, 2011 at 16:48
  • I am doing this from an api so ofcourse it must permit me cross domain stuff. Commented Aug 25, 2011 at 16:53

2 Answers 2

2

Do you know what 204 means?

204 No Content The server successfully processed the request, but is not returning any content

http status codes

The server is saying it was good and there is nothing to return.

Sign up to request clarification or add additional context in comments.

1 Comment

But when I upload the photo. I don see them in the picasa album
1

The problem is with dojo.xhrget, not with your syntax or picasa. Look in the net panel in firebug and you'll see that dojo.xhrGet does not send the session cookie in the request header s that picasa requires.

Try using jQuery.Get and you'll find it works fine.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.