jQuery upload plugin to work with JSP/Java - javascript

I'm trying to accomplish the following:
Upload a file to the application by submitting a form (enctype: multipart/form-data) to a JSP action which handles the rest (including writing the file to the disk, processing and returning some xml data about the upload).
Until recently, I was using this plugin:
http://valums.com/ajax-upload/
This does not work well for two reasons:
it breaks on Internet Explorer
the code is written in half jquery, half native javascript and not in your usual plugin authoring form, which makes it harder to debug.
I've also looked at Uploadify ( http://www.uploadify.com/ ) but it takes a radically different approach which would require a lot of back-end changes.
Do you know any similar submit-form-in-hidden-iframe plugins that are cleaner / cross-browser compatible? Or alternative solutions that I'm missing?
Please note that I can't use a regular because of the specific requirements.
Thanks.

You can try:
https://github.com/blueimp/jQuery-File-Upload
Pretty nice & simple

It's not jQuery but this is quite nice.
http://digitarald.de/project/fancyupload/
Also YUI has an uploader.

I've had success with this one:
http://malsup.com/jquery/form/

Allthough this is not a JQuery plugin, I can recommand SwfUpload for this kind of functionality. It's a combination of Flash and javascript which allowed me to do exactly what I wanted to without having to worry about the "upload"-part.

Try jqUploader : it's written in pure jquery plugin style and uses a flash file to display a progress bar. Very easy to implement.

You may try: plupload. It's back-end independent, and cross-browser.

Related

Editing a jQuery script so the new version has code I need to make a gallery work

I read a post answer that you can do search for the code I need from an old version of jQuery and copy it and paste it into a newer version jQuery script. This way I don't have to try and have two versions of jQuery to load at the same time which was unsuccessful. Both the jQuery scripts I have are .min
How do I do this? See the person's answer below
Why would you need two jQuery libraries anyway?! Just use the newer one! ... Let's even say you needed the old one because you need some functions that aren't available in the new framework. Just look them up in search mode and copy past them one by one to the new framework (can only be done if you use jQuery offline like me, which saves loading time during developpement cause it gets cached.) P.S: I hope this doesn't cause any copyrights infrigments.
Editing jquery is very bad practice, do it only for very small projects which maintenance won't have any work with jquery or component updates at all!
Better try using Jquery Noconflict library.

What is the usage of JavaScript in bootstrap?

I am learning bootstrap. As I can see, it is pretty straight forward to use it. I tried to use the framework without including any reference to the JavaScript files and it is working just fine (at basic level).
So my question is - can I just ignore the JavaScript files and use only the css-based grid system, or the css depends on JavaScript in some way and I just don't face it now.
Thank you!
As long as you don't need anything from this page you can skip loading the javascript asset.
YES, If you do not need any javascript related component (modal,tab etc.) ,
Also please remember you could customize entire framework with link below:
http://getbootstrap.com/customize/
Just check what you want and download.

Is it Ok to use 2 Javascript Libraries on One HTML Page?

I know PHP and MVC but when I work on Joomla I dont want to learn Mootools for AJAX , I rather include jQuery which I know thoroughly. I think IMHO jQuery has the largest mindshare in AJAX Libraries.
When I work on Magento , instead of using bundled prototpye , I use jQuery . Same is the case with SocialEngine where I dont use the bundled mootools , but jQuery what I know better.
Personally I think it is ok to include 2 Javascript Libraries on one HTML Page because it doesnt puts any Extra Procesing load on the Server . Even in the Client Browser I dont find any performance Issues . Moreover , since jQuery is loaded from Google CDN so there is every chance that Browser Cache already has it .
What do you think , Is it ok to include 2 Javascript Libraries on 1 HTML Page ?
It's technically ok as long as the libraries don't conflict with each other (i.e. both try to bind the $ as a function) and you don't notice terrible performance for your end users.
That being said, each javascript library that you include adds extra requests and processing on the client side. While you may not notice an impact on your development computer (usually a high powered beast), you end users on their $200 laptops may not be so fortunate.
As much as possible try to only include the portion of the library that you need and concatenate libraries into a single file to cut down on the HTTP requests.
I don't see a reason why you shouldn't be able to use more than one library at the same time. In some cases you will have to take care of possible conflicts, e.g. if both use the $ symbol/function.
See this page for more information: Using jQuery with Other Libraries
Yes this is done all the time. View source on this page and you will see at least 2 included libraries.
There is no particular problem if you don't use 2 libraries which alter the prototypes.
jQuery doesn't do that so you can use it with any other library.
The major librairies which alter the prototypes are MooTools < 2, dojo < 2 and Prototype < 2.

What is the best, light-weight JSON/ajax script?

I am creating a joomla plugin and want to load an array of images after the page has loaded. To do that, I'm currently using mootools.js to call myserver URL, obtain the JSON response and parse the response into javascript variables that represent each image url. It works great, but mootools.js is appropriately named since it is a real heffer in the size department.
Is there a lightweight script out there that will make the ajax call and parse the JSON object? The smaller the better.
I just found a JSON parser, json2.js, at json.org that minifies down to about 3k. You basically do a standard HTTPRequest via AJAX and then pass the response text to the JSON parser to create the JSON object.
Thanks for all the answers and I did track them all down. I couldn't get any of them small enough to compete with this approach, though.
There are quite a few javascript frameworks out there in addition to Mootools that can accomplish what you're looking for. I recommend taking a look at Jquery or Prototype. They're very similar to Mootools and the mini-fied versions may provide the lightweight solution you're looking for:
http://jquery.com/
http://www.prototypejs.org/
If it's lightweight you want, I can suggest Net.js.
http://xkr.us/code/javascript/Net/
However, it doesn't support parsing of JSON, but that is simply one row of code, getting the responseText and calling eval on it:
var json = eval('(' + xhr.responseText + ')');
Downsides:
Timeout is not configurable. However, easy to modify directly in the source.
No support for a request-group with common finish-handler. Each request is individual.
Two suggestions:
Find a library that breaks the functionality you need down into relatively small components. Then download only the components you need. YUI is nicely divided, but even those files can be somewhat larger than necessary. A smaller project that is based on YUI is Fork. Find this library at http://forkjavascript.org
Find the functionality you need in one of the open source libraries and refactor it into your own significantly smaller version.
I don't know what particular version of MooTools you're using, but it doesn't have to be large if you tailor it specifically to your needs. MooTools provides an advanced download page that will allow you to create a custom-built, minified version of the library in a single file. Try it out and see if it suits your needs. If it does, you won't have to go and learn prototype/jquery/etc.
Edit: I just tried downloading MooTools' Request.JSON package with all dependencies. With the YUI compression option, the file size came out to 33.8KB.

What is the best way to upload a folder to a website?

I need an easy way to allow users to upload multiple files at once (ie I need to allow a user to upload a folder). I do not wish to put the burden of zipping on the user.
I would prefer to avoid Flash or variants if possible. I'm looking for a straight javascript / HTML solution if it is possible. Please note, this rules out the answers at: What is the best client side browser library to upload multiple files over http?.
You won't be able to do it with just HTML and Javascript. I'd recommend trying Fancy Upload, a MooTools plugin for multiple file uploads. It uses a mixture of JavaScript and Flash, but degrades gracefully. It works with all major browsers including IE6 and there is also a Flash 10 compatible release available for download (though the demo hasn't been updated yet).
Update (2012-11-26):
Multiple file uploads are possible with valums or blueimp file uploaders.
For recursive directory uploads, your best solution is using Chrome 11's new folder upload API. It also seems to work on Firefox if you use a vendor prefix.
With Firefox 42 and Edge having implemented the new directory upload proposal we'll finally able to do cross-browser directory uploads. The APIs are nasty enough that you may want to check out my wrapper, uppie.
If you're avoiding Flash (and presumably Java?) the JS/HTML-only solution still requires single-file inputs, but essentially you attach an onchange event to your input, adding a new input to the DOM whenever a file is selected.
Multiple file uploads are possible with valums or blueimp file uploaders.
For recursive directory uploads, your options are more limited:
Your best solution is using Chrome 11's new folder upload API. It also seems to work on Firefox if you use a vendor prefix.
This is also possible cross-browser with a Java applet. However the % of folks with a JRE installed has gotten pretty low these days (< 70%)
This isn't a pure js/html solution. As EndangeredMassa has pointed out, it's not possible. In fact, this idea is an IE/Windows only solution. I don't recommend it, but it can work.
So, all disclaimers aside ...
Many years and several employers ago, we used to do some client side stuff that instantiated the FileSystemObject. It would iterate through each of the files and pass them through to the server one at a time. Can't remember the details of how we did that :o(
Anyway, this usually meant that the client box would need to have to add the site to the list of trusted sites and give trusted sites a bunch of permissions that are turned off (for very good reasons). Stuff like the ability to Initialize and script ActiveX controls not marked as safe. That kind of thing.
I know that this isn't a perfect answer, but it could point you in the right direction.
FTP? And if necs, wrap in Java Applet, ActiveX or whatever you want.
If not, although you don't want flash, SWFUpload is quite cool, you may want to reconsider it as a decent option.
Here is pure JS solution using ExtJS library

Categories

Resources