Error with Ajaxsubmit

Asked

Viewed 362 times

1

In 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 function on Controller, where everything passes correctly and works everything (save file, among other tasks I am doing). But how I wanted to use the success I have this problem... No error of .ajaxSubmit() also does not contain relevant information.

  • Cesar, the problem is in this very role?

  • Yes @Renan. That’s right when I click a button to call the function guardarDocComprovaticoProdOSCli()

  • Which jQuery version is using?

  • @Guilhermenagatomo 1.10.3

  • This is looking more like a missing jquery library error.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.