[英]from pure javascript to prototypejs
Is there a way to write the following pure javascript in prototypejs 有没有办法在prototype.js中编写以下纯JavaScript
var xhr = new XMLHttpRequest();
xhr.open("POST", "/photos?authenticity_token=" + token
+ "&photo[name]=" + img.name
+ "&photo[size]=" + img.size);
xhr.overrideMimeType('text/plain; charset=x-user-defined-binary');
xhr.sendAsBinary(bin);
I did this but I don't know how to upload the bin
file 我这样做了,但我不知道如何上传bin
文件
var url = '/photos';
new Ajax.Request(url, {
method: 'post',
parameters: {
authenticity_token: token,
'photo[name]': img.name,
'photo[size]': img.size
},
onSuccess: function(transport) {
alert('Yeah');
}
});
thanks 谢谢
sendAsBinary
方法是FireFox特有的,因此未在prototypejs库中实现,因为该库旨在跨浏览器工作。
Darin Dimitrov is spot on. 达林·迪米特洛夫(Darin Dimitrov)独树一帜。
However if it's ajax file uploading you're ultimately after i'd suggest yahoo's uploader. 但是,如果它是ajax文件上传,那么您最终还是会建议雅虎的上传者。 Simple example: http://developer.yahoo.com/yui/examples/uploader/uploader-simple-button.html 简单示例: http : //developer.yahoo.com/yui/examples/uploader/uploader-simple-button.html
仅供参考swfupload也是可靠的文件上传器,不需要任何库
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.