Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/415.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Javascript XMLHttpRequest将图像发布到Picasa_Javascript_Ajax_Post_Xmlhttprequest_Picasa - Fatal编程技术网

使用Javascript XMLHttpRequest将图像发布到Picasa

使用Javascript XMLHttpRequest将图像发布到Picasa,javascript,ajax,post,xmlhttprequest,picasa,Javascript,Ajax,Post,Xmlhttprequest,Picasa,我正在尝试使用javascript向picasa发布一个图像。我有所需的代币。但是当我发布时,我得到一个错误“204无内容” 这是我的密码 function send() { var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { if(xhr.readyState == 4) alert(xhr.status); } xhr.open("POST","https://picasaweb.google.com/

我正在尝试使用javascript向picasa发布一个图像。我有所需的代币。但是当我发布时,我得到一个错误“204无内容”

这是我的密码

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());

}

你知道204是什么意思吗

204无内容服务器已成功处理请求,但 不返回任何内容


服务器说它很好,没有任何回报。

问题在于dojo.xhrget,而不是语法或picasa。查看firebug中的网络面板,您将看到dojo.xhrGet没有发送picasa所需的请求头中的会话cookie


尝试使用jQuery.Get,您会发现它工作正常。

如果您尝试从picasaweb.google.com以外的其他域执行该请求,则该请求将阻止您。但他会得到204响应,所以这不会是问题所在?只是吹毛求疵:“204无内容”不是错误。2xx类用于成功代码。引用RFC,204表示“服务器已完成请求,但不需要返回实体正文,并且可能希望返回更新的元信息。响应可能以实体头的形式包含新的或更新的元信息,如果存在,则应与请求的变量相关联。”@mcb某些浏览器在您发出跨域XHR请求时确实会使用204头结果。我是从api执行此操作的,因此当然它必须允许我跨域操作。但是当我上载照片时。我在picasa的专辑里没看到他们