How to AJAX WITH JQUERY sending a POST?

Asked

Viewed 647 times

-1

Hi I want to send Two valore, one via Post and one via GET to my funcoes.php in this post I want to send as get the type of request to validate it in the functions and also the date that the client selected from the calendar. via POST

How do I do?

 $('#agenda_profissional_online').datepicker().on('changeDate', function(e) {

        var agendaData = $('#agenda_profissional_online').datepicker('getDate');
        agendaData = agendaData.toLocaleDateString("pt-BR");
        $.ajax({url: "funcoes/funcoes.php?solicitacao=HORAS_DISPONIVEIS", success: function(result){


        }});

    });

1 answer

0


Use the ajax options method (v1.9+) or type (up to v1.8) with the value "post" and send the value via data:

$('#agenda_profissional_online').datepicker().on('changeDate', function(e){
   var agendaData = $('#agenda_profissional_online').datepicker('getDate');
   agendaData = agendaData.toLocaleDateString("pt-BR");
   $.ajax({
      data: {agendaData: agendaData},
      method: "POST",
      url: "funcoes/funcoes.php?solicitacao=HORAS_DISPONIVEIS",
      success: function(result){
      }
   });
});

The variable solicitacao shall be sent via GET, and agendaData via POST.

Browser other questions tagged

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