Как отправить значение из диаграммы Google в URL через AJAX? - PullRequest
0 голосов
/ 14 ноября 2018

хочу отправить переменную топинга в URL через ajax , и я использую 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 Ответ

0 голосов
/ 14 ноября 2018

для передачи по URL, используйте "GET" запрос ...

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

для "POST", используйте клавишу data ...

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