Send content from an index to an Edit via AJAX with . NET

Asked

Viewed 18 times

0

I’m creating an approval screen and when the user clicks fail will appear a pop-up to describe the reason for the refusal ... The problem is that I am not being able to send via AJAX the information inserted in the pop-up, the approval screen together with the pop-up is on the index and I want to send this information to another controller.

  function pegarInformacoes() {

        var mensagem = document.getElementById("message-text").value;
        console.log(mensagem);
        var id = document.getElementById("buscarid").textContent;
        console.log(id);
        EnviaDados(mensagem, id);

    }

in the var message it takes the content obtained in the response box,and in the id it takes the id of the column.

 function EnviaDados(mensagemreprov,numeroid) {
        $.ajax({
            url: '/AprovacaoMudanca/Index',
            method: 'POST',
            data: { "Motivo": mensagemreprov, "AprovacaoMudancaId": numeroid  },
            dataType: 'json',
            success: function (data) {

                alert("sucesso!");

            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                if (XMLHttpRequest.status === 0) {
                    alert(' Check Your Network.');
                } else if (XMLHttpRequest.status === 404) {
                    alert('Requested URL not found.');
                } else if (XMLHttpRequest.status === 500) {
                    alert('Internal Server Error.');
                } else {
                    alert('Unknow Error.\n' + XMLHttpRequest.responseText);
                }
            }
        });
    }
  • You have to better describe the error that is happening. There is no apparent problem with your code.

  • Why the post for the route /AprovacaoMudanca/Edit/VariavelComiD doesn’t work? You have a method with annotation [HttpPost] responding to it in your controller?

No answers

Browser other questions tagged

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