开发者

Upload file and parameters with ajax request, pure javascript or prototypejs

开发者 https://www.devze.com 2022-12-20 16:28 出处:网络
I want to 开发者_Python百科upload a file using an ajax request var xhr = new XMLHttpRequest(); xhr.open(\"POST\", \"/photos\");

I want to 开发者_Python百科upload a file using an ajax request

var xhr = new XMLHttpRequest();

xhr.open("POST", "/photos");

xhr.overrideMimeType('text/plain; charset=x-user-defined-binary');
xhr.sendAsBinary(bin);

Works fine, but I want to post a parameter with this request ie: token=abc123

How can give a parameter to this request?

this is pure javascript, if you have the answer using prototypejs it's even better

Thanks a lot


You can still append query string parameters in a POST Request:

xhr.open("POST", "/photos/?token=abc123");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号