How to Send value from google chart in url through ajax?

Viewed 70

want to send topping variable in url through ajax and i am using laravel framework

        function selectHandler() {
            var selectedItem = chart.getSelection()[0];
            if (selectedItem) {
                var value = data.getValue(selectedItem.row, selectedItem.column);
                var topping = data.getValue(selectedItem.row, 0);
                var columnLabel = data.getColumnLabel(selectedItem.column)
                // alert('The user selected ' + columnLabel + ': ' + topping + ' - ' + value);

                $.ajax({
                    type: "POST",
                    url: "/datesalesbarchartdata/" + topping,
                    dataType: 'json',

                });


            }
        }
1 Answers

to pass on the url, use "GET" request...

$.ajax({
  type: "GET",
  url: "/datesalesbarchartdata?topping=" + topping,
  dataType: 'json',
});

for "POST", use the data key...

$.ajax({
  type: "POST",
  url: "/datesalesbarchartdata/",
  dataType: 'json',
  data: {
    topping: topping
  }
});
Related