need to specify url in @ html.beginform when using $ .ajax?

1

I have an application in MVC ASP.NET and I have created a form with eight fields based on a model, my question is this:

If I want to use jQuery-AJAX-JSON in the click event of my submit button to send my model to the controller, it means then that it is not necessary to specify the action in the form created from the model:

@Html.BeginForm("accion", "controller", FormMethod.Post

since it is specified in:

$.ajax({
    url: 'acción/controller'
});

??? thanks for the help

    
asked by Pablo Mayora 02.04.2017 в 16:55
source

1 answer

1

If you use $.ajax then you do not use @Html.BeginForm() , or it is not necessary, you could just use a <form id="form1"> and that is enough if you want to serialize the form to send it in $.ajax

Web API With AJAX: Submit Form Data After Serialization

Analyze how you use the

$('#form1').serialize()

to send the data by ajax, but you do not need the form that defines the helper of mvc, you can hacelro simply with the tag form of html.

Unless you are evaluating using the @ Ajax.BeginForm () in that case if you were implementing an ajax call using the mvc helper.

    
answered by 03.04.2017 / 14:57
source