Search code examples
javascriptjqueryajaxjquery-pluginsajaxform

Jquery ajaxForm() doesn't fire 'success' although it works successfully


Today I was trying to send files via Ajax request using the JQuery AjaxForm plugin. However, it doesn't fire the success function as it uploads the file without any javascript run time or compile time error.

Here is my code:

<table id="haberresmiekle">
<form action="action.asp?kmt=resimyukle" method="post" enctype="multipart/form-data" id="haberresmiekleform">
<tr>
    <td><input type="file" name="file"></td>
</tr>
<tr>
    <td><input id="b" type="submit" value="Gonder"></td>
</tr>
</form>
</table>

and

<script> 
$("#haberresmiekle").dialog({autoOpen:false,title:"Resim Yukle"});
        var options={
                target:"#haberresmiekle",
                success:function(){alert('x');$("#haberresimekle").dialog('close');}
            };
        $("#haberresmiekleform").ajaxForm(options); 
$("#b").button();
</script>

Thanks for any help

Note: It has been resolved.


Solution

  • Yor script will do nothing(except in IE) as long as you dont use valid selectors.

    $(haberresmiekleform)-> $('#haberresmiekleform')
    $(haberresmiekle)    -> $('#haberresmiekle')
    $(button)            -> $('#button')