Welcome Guest, Not a member yet? Register   Sign In
uploading using ajax and uploading class
#11

[eluser]yannyannyann[/eluser]
[quote author="phazei" date="1233844324"]I suppose after you post you stop racking your mind so the solution comes to you… like not disabling the <input type=file> in the preSubmit function without using setTimeout…[/quote]

Can you explain more in details ?
I have the some problem as you had and I'd like to slove it Smile

I have one file to upload and this is my jQuery :

Code:
jQuery("#addVideoForm").validate({
        rules: {
            userfile: {
                  required: true,
                accept: "mov|avi|mpg|flv"
            }
        },
        submitHandler: function(form) {
            jQuery(form).ajaxSubmit({
                target:        '#positive-result',  
                beforeSubmit:  showRequest,
                success:       showResponse  
            });
        }
    });    

    function showRequest(formData, jqForm, options) {
        $('#result').fadeIn("slow");            
        $('#positive-result').html("Upload en cours...");
        var queryString = $.param(formData);
        return true;
    }

    function showResponse(responseText, statusText)  {    
        
        $('#positive-result').html( 'La video a bien été ajoutée. <a href="&lt;?=base_url()?&gt;admin/videos">Retour à la liste</a>');
        $('#result').fadeIn("slow");    
    }
#12

[eluser]phazei[/eluser]
Oh, what I was doing wrong was something like
$('input[type=file]').attr('disable','true');
So people couldn't click the button again. That was done in the "beforeSubmit" function. Disabled input fields aren't submitted, so that was my brain fart.

I don't know what's wrong with your code.

Though, if you are only using the jQuery validation plugin, it won't work. You can't specifically upload a file directly through AJAX. Not possible. You can get ajax like functionality with the jQuery form plugin or a number of other ones. The form is actually submitted in a hidden iframe the normal way. But it appears just like ajax.
#13

[eluser]e-mike[/eluser]
See Single, Multiple and Multiple array upload library for a very simple jQuery upload example...




Theme © iAndrew 2016 - Forum software by © MyBB