0

Hy every body, i am a new people in here, so i am need all of your help, please..

i have the script ajax like this,

<script type="text/javascript">
jQ(document).ready(function() {

     jQ().ajaxStart(function() {
         jQ('#loading').show();
         jQ('#result').hide();
    }).ajaxStop(function() {
         jQ('#loading').hide();
         jQ('#result').fadeIn('slow');
    });

     jQ('#frm').submit(function() {
     var formData = new FormData($(this)[0]);
        jQ.ajax({
            type: 'POST',
            url: jQ(this).attr('action'),
            data: jQ(this).serialize(),
            success: function(data) {
                jQ('#result').html(data);
            }
        })
        return false;
    });
})
</script>

That code is succes to upload the data to database except the file (image) whats should i do so the file image also uploaded to database?

i have try with this code,

$("form#data").submit(function(){

    var formData = new FormData($(this)[0]);

    $.ajax({
        url: window.location.pathname,
        type: 'POST',
        data: formData,
        async: false,
        success: function (data) {
            alert(data)
        },
        cache: false,
        contentType: false,
        processData: false
    });

    return false;
});

and both of data and file (Image) succes uploaded to database, but the animasi when uploaded to database is lost, what should i do so the data and file (image) inserted to database, but using animasi like my first code...

thanks, for your any help...

3
Contributors
2
Replies
11
Views
5 Years
Discussion Span
Last Post by pixelsoul
0

and both of data and file (Image) succes uploaded to database, but the animasi when uploaded to database is lost, what should i do so the data and file (image) inserted to database, but using animasi like my first code...

The second code looks wrong. You can read and see how a ajaxSubmit to submit the form looks like and function:

http://malsup.com/jquery/form/#ajaxSubmit

0

To add to this, I would recommend against storing your images in a database. Rather store them in a folder and then just reference the location/filename in the database. It's much more efficient.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.