在输入文件更改事件中,我正在执行以下代码。
致电FB.api - ,但这绝不会 被执行。 - 出了什么问题?
var fData = new FormData();
var imgFile = $('input[type="file"]')[0].files[0];
fData.append("image", imgFile);
alert('before calling FB.api-post :' + imgFile.name);
var params = {
"access_token": $D("access_token"),
"message": $D("img_message"),
"upload file": true,
"source":fData
}
FB.api('/me/photos', 'POST', params,
function (response) {
alert('asasasasasasasasasasasasas');
if (!response || response.error) {
$D("preview").innerHTML = "Error in facebook Photo UPLOAD : " + response.error;
alert('Error in facebook Photo UPLOAD : ' + response.error);
}
else {
$D("preview").innerHTML = "Photo UPLOADED : " + response;
alert('uploaded');
}
}
);
});
注意:$ D只是以下快捷方式
function $D(element) {
return document.getElementById(element);
}