Home > Back-end >  My $_GET is showing me empty string as a value
My $_GET is showing me empty string as a value

Time:11-23

When I debug my $_GET as a parameter shows value that I want to display as value and where the value is it is showing me just empty string.

enter image description here

So I want on that place to be "reservationData" and {"thename":"Maja_Bj","themovie":"1","theday":"Saturday"} to be shown as value. I already defined thename, themovie, theday. Im just having trouble with switching positions with name and value of $_GET

Here is my code:

var reservationData = {}
console.log(reservationData);
debugger;
confirmReservation.on('click', function(){

  $.ajax({
    url: '/drupal/movie-reservation',
    type: 'GET',
    cache: false,
    data: JSON.stringify(reservationData),
    success: function(data){
      if(data.status == 'success'){
        alert("Success! Your information has been saved!");
      }else if(data.status == 'error'){
        alert("Error! Please try again...");
      }
    }
  });

CodePudding user response:

Try this,

data: {'reservationData':JSON.stringify(reservationData)}
  • Related