Post does not send the information

Asked

Viewed 159 times

3

I need to send some information by POST to my controller, and at the same time pass a parameter in the URL. The Url Parameter I can take it easy, the problem is that the POST parameters will not.

I am using this function to generate a form and send with the information:

function paginacao(pagina,BASE_URL){
        var url = BASE_URL+"acompanhamento/Aluno/"+pagina;
        var hiddenForm = $("<form method='post' action='"+url+"'>"+
          "<input type='text' id='campoParam' value='"+$('#campo').val()+"'>"+
          "<input type='text' id='dataInicialAvaliacaoParam' value='"+$('#dataInicialAvaliacao').val()+"'>"+
          "<input type='text' id='dataFinalAvaliacaoParam' value='"+$('#dataFinalAvaliacao').val()+"'>"+
          "<input type='text' id='cursoAvaliacaoParam' value='"+$('#cursoAvaliacao').val()+"'>"+
          "<input type='text' id='paginaParam' value='"+$('#pagina').val()+"'>"+
          "<input type='submit' id='btnSubmitParam' value='"+$('#pagina').val()+"'>"+
          "</form>");
          $('body').append(hiddenForm);
          $('#btnSubmitParam').click();
          //hiddenForm.submit();
      }

I have already checked the variables within the values and they bring the expected value. But when I try to give a var_dump($_POST). on the controller, I get Empty

inserir a descrição da imagem aqui

The variable pagina that goes in the URL(second line) is the parameter that goes in get, the method is POST as it should, but still the controller does not receive

If any information is missing, please let me know!

NOTE: I have tried to pass only the POST parameter without the variable in the url and the result was the same

2 answers

4


You need to add the name attribute in the input fields they are used to reference after the form is submitted.

-1

You must put the name attribute in the input fields, in the $_post[' chapter here you give the name of the field you placed in the ']; you will give the name you want inside the brackets.

Browser other questions tagged

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