Hi Mike and all

I've read the documentation on uploading a file via the form plugin
and JSON, but I simply can't get it to work. The form plugin dies as
soon as I submit it... no error is thrown, but it posts the whole page
like a normal form and no response is given.

Here's my form code:

<form action="http://localhost/media/add"; method="post" class="form-
std" id="form-add-media" enctype="multipart/form-data">
<input name="sid" value="1" type="hidden">
<input name="stype" value="1" type="hidden">
<input name="m" value="i-image" type="hidden">
<div id="add-m-e"></div>
<div id="add-m-i">
        <div style="display: block;" class="m-type" id="i-image">
        <p>
             <label for="m-image">Choose an image to upload</label>
             <input name="m_image" type="file">
       </p>
       </div>
</div>
<div id="add-m-r"></div>
<p class="form-buttons"><input name="m_submit" value="Add"
type="submit"></p>
</form>

Here's my JS:

$('#form-add-media').ajaxForm({
                beforeSubmit: function(a,f,o) {
            o.dataType = 'json';
            var queryString = $.param(a);
            console.log(queryString);
            //return false;
        },
                success: function(d) {
                        if(d.error) {
                                $('#add-m-e').html(d.msg);
                        }
                        else {
                                $('#add-m-e').empty();
                        }
                }
        });

Thanks for any help you can provide!

Reply via email to