Form Ajax + Dialog Jquery C # MVC

3

Good morning, I am trying to use a form

asked by Ariel Octavio D'Alfeo 14.01.2016 в 19:25
source

3 answers

4

I understand that the problem is presented in the "Add" button of the popup, it makes a submit of the form, which is inside an Ajax.BeginForm.

If the main page has another form defined this can cause problems, remember that there can be no nested form tags, you should remove the form from the main page.

Although I would recommend that you evaluate sending the popup data using ajax but using the $ .ajax of jquery and not by means of the Ajax.BeginForm ()

Sending JSON to an ASP.NET MVC Action Method Argument

This way you control the call and there is no submit of a form

    
answered by 14.01.2016 / 21:06
source
0

Verify that the JS jquery.unobtrusive-ajax.js is not being duplicated, since you are calling the JS at the beginning and in the script section when calling the bundle jqueryval ; to avoid the submit you can make the AJAX request with $.ajax of jQuery.

Good luck.

    
answered by 19.01.2016 в 16:16
0

You can use:

$("#submit").on('submit', function(event){
    event.preventDefault();

    [Ajax de envio de datos al controlador]

    return false;
});

With the event.preventDefault() you avoid the send function of the submit, and you can send all the data by an AJAX to the controller.

This avoids postback and you can render what you want in the same view that you already have open.

    
answered by 28.12.2016 в 20:20