Piotr Sarnacki home

JSON-P support for Apache upload progress

Just a quick note about new feature added to apache upload progress and jquery upload progress libs.

Ron Evans aka deadprogrammer has added support for JSON-P in this commit. What does it mean? Cross domain requests are now possible, so if you need such a functionality pull the newest changes.

Here is Ron’s description from README:

- JSON-P Support

You can also request progress updates by using JSON-P, if you are uploading the file from a different domain or subdomain than the web server that is handling your original request. Adding a “callback=yourCallbackFunction” parameter to your request to the progress server will activate this functionality.

For example, a request like:

Would return the JSON-P function:
jsonp123(new Object({ ‘state’ : ‘uploading’, ‘received’ : 35587, ‘size’ : 716595, ‘speed’ : 35587 }));

The normal JSON request:

Would return the JSON data:
new Object({ ‘state’ : ‘uploading’, ‘received’ : 35587, ‘size’ : 716595, ‘speed’ : 35587 })

Remember to update jquery upload progress also, to use jsonp.

Enjoy :)

If you liked this post consider following me on twitter.
blog comments powered by Disqus
Fork me on GitHub