Is it possible to two Ubmit a button?

Asked

Viewed 48 times

0

Possible, within one click the call of two Ubmit?

Here’s my problem, I need inside a button, to be called two Actionresult in sequence.

Follow what I’ve done so far:

    $('#enviarPreProposta').click(function () {
    var telefoneValido = ValidarTelefones();
    var idUltimoTelefone = $('#tblTelefones tbody tr:last td:first input').val();
    if (idUltimoTelefone == undefined) {
        MessageBoxKo('É obrigatório a inclusão de pelo menos um telefone.', 'Atenção', null, null, null, null);
    return false;
    }

    var retorno = ValidarCamposNecessarios();
    if (retorno == true && telefoneValido) {
        DesabilitarCamposResposanvelFinanceiro();
        $('#frmVendaEletronica').attr('action', '../VendaAdministrativa/ValidarCampos')
        $('#frmVendaEletronica').submit();
        $('#frmVendaEletronica').attr('action', '../VendaAdministrativa/EnviarPrePropostaAceitacao')
        $('#frmVendaEletronica').submit();
    }
   });
  • At each request the page is regarregada, therefore it is not possible and not very logical to make two "submits", because in the first Ubmit the page already loads. But there is a solution, Ajax, however you will have to modify the back-end interface to be able to get the answer, using a more ajax-friendly format like Json for example. Yet instead of ajax maybe it’s better you create a single route where all back-end events occur instead of having two routes.

  • You can put a return RedirectToAction() in an action or work with Viewmodels for it. Post what you need to do that will be easier to help you.

  • @Randrade, then my dear, the problem is : I have an actionResult that returns to the screen a Dialog, and I can only follow with the system flow, if the user fills or closes this dialog, in sequence, the application calls another actionResult.

  • If you add how you are returning this dialog and this comment information in the question, it will be easier to help you. Explain what you really need to do.

1 answer

2

It is not possible but you can use $.post(), for example:

var dado1 = '123';
var dado2 = '456';
$.post('../VendaAdministrativa/ValidarCampos',{'dado1':dado1,'dado2':dado2},callback(){
  var dado1 = '789'; 
  var dado2 = '91011'; 
  $.post('../VendaAdministrativa/EnviarPrePropostaAceitacao',{'dado1':dado1,'dado2':dado2},callback(){
      //FIM
  }
})
  • When formatting code, use the markdown by selecting the code and clicking the button {}

  • vlw, thank you very much

Browser other questions tagged

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