1

This is my first exposure with using Mootools; I have not used Jquery much, and I am having troubles implementing a new change to the scripting.

We used a flash uploader, FancyUpload2 and I have been tasked with replacing it with a non-flash version. I am attempting to use the existing coding for the rest of the project, but I have not been able to get this to work now.

<script type="text/javascript">
$('#demo-browse').change(function(){    
    //on change event  
    formdata = new FormData();
    if($(this).prop('files').length > 0)
    {
        file =$(this).prop('files')[0];
        formdata.append("Filedata", file);

    }
        jQuery.ajax({
    url: '../control/image_upload/gallery_script.php',
    type: "POST",
    data: formdata,
    processData: false,
    contentType: false,
    success: function(response)  {
            var json = new Hash(JSON.decode(response, true) || {});
        //  alert(response);
            iDependOnMyParameter(response);
        }
    });
    function iDependOnMyParameter(param) {
    // You should do your work here that depends on the result of the request!
    var json = new Hash(JSON.decode(param, true) || {});

             var req = new Request({
                   url: '../control/image_upload/gallery_script_ajax.php',

                    onSuccess: function(response){

                        var feedback = response.split('|');
                        var thumb = feedback[0];
                        var new_id = feedback[1];

                        var li = new Element('li', {id: 'item_'+new_id, 'class':'sort_me', 'alt':new_id});//create new list item
                        alert(new_id);

///// CODING WORKS UP TO HERE

                        sb.addItems(li);//add to sortables
                        var first_item = $('content_list_images').firstChild; // get current first li
                        $('content_list_images').insertBefore(li, first_item);// insert into list
                        li.set('tween',{duration: 2000});
                        li.tween('opacity', 0, 1);

                    },
                    onFailure: function(){

                    }

            });
            var data = 'file='+json.get('filename')+'&extension='+json.get('extension')+'&date='+json.get('date')+'&width='+json.get('width')+'&height='+json.get('height')+'&mime='+json.get('mime')+'&page_id=<?=$id?>&new=<?=$unix?>';

            req.send(data);
                ////////////////////////////////////////////////
                }         

});

</script>

I have been able to hack some things together to have it work how I need, but then I get to a certain point and I am not sure how to continue. All the posts get the responses that I need, but then I am at a loss. I would greatly appreciate some assistance as to how I am able to make this work.

Everything up to alert(new_id); works.

I am fully aware that I need to review more with Jquery and Mootools, and I will do so. I am on a tight deadline and I do appreciate any and all help!

The previous tools that they used to upload files was using FancyUpload.

0

Browse other questions tagged or ask your own question.