Error with AjaxSubmit

1

When doing .ajaxSubmit() of a form with a input type="file" I always get the error:

  

Uncaught TypeError: jQuery (...). data (...) is not a function

Form:

@using (Html.BeginForm("guardarDocComprovaticoProdOSCli", "OrdemServicos_Clientes", FormMethod.Post, new { id = "formSaveFile", enctype = "multipart/form-data" }))
{
    <input type="file" name="filepath" id="filepath" />
    <br />
}

JS function:

function guardarDocComprovaticoProdOSCli() {
    if ($('#filepath').val() != "") {
        $("#formSaveFile").ajaxSubmit({
            type: "POST",
            data: { idProdutoOSCli: window.idProdutoOSCli },
            success: function (result) {
                alert(result);
                $('#myModal').modal('hide');
            },
            error: function (a, b, c) {
                alert(b);
                alert(c);
            }
        });
    }
}

Controller:

[AcceptVerbs(HttpVerbs.Post)]
public JsonResult guardarDocComprovaticoProdOSCli(int idProdutoOSCli)
{
    HttpPostedFileBase filepath = (HttpPostedFileBase)Request.Files[0];
    var nameFile = "" + idProdutoOSCli + "_AnexoComprovatioProdOSCli_" + filepath.FileName + "";
    ...
    return Json("Doc. carregado", JsonRequestBehavior.AllowGet);    
}

I get this error before going to the function in Controller , where everything goes correctly and everything works (save file, among other things I'm doing). But since I wanted to use success I'm having this problem ... error of .ajaxSubmit() also does not bring relevant information.

    
asked by anonymous 23.04.2015 / 18:08

0 answers