使用ajax框上传文件

I try to upload a file using Box.com API from https://gist.github.com/seanrose/5570650.

I received the following error:

`XMLHttpRequest cannot load "https://upload.box.com/api/2.0/files/content". No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin localhost' is therefore not allowed access."

What can I do? How can I upload files to Box.com using AJAX?

This is documented in the Box Developer Docs under the topic CORS. You need to visit your Box Application Configuration page and add the comma separated list of addresses/IPs to the CORS Allowed Origins field. For example:

enter image description herehttp://127.0.0.1,http://localhost,http://localhost:3000,http://10.0.1.2,http://0.0.0.0,https://example.com