$.ajax({
method: 'POST',
url: 'url',
success: function (data) {
var month=[];
var device=[];
$.each(JSON.parse(data), function(index, report)
{
month.push(report.month)
});
$.each(JSON.parse(data), function(index, name)
{
device.push(name.devices)
});
//Build chart
var ctx = document.getElementById('chart').getContext('2d');
regionChart = new Chart(ctx, {
// The type of chart we want to create
type: 'horizontalBar',
dataType:'json',
// The data for our dataset
data: {
labels: month,
datasets: [{
label: "Chart",
data: device,
}]
},
});
}
});
$('#form_vac').on('submit', function ()
{
var name = $("#name").val();
var number = $("#number").val();
var age = $("#age").val();
var exp = $("#exp").val();
var text = $("#text").val();
var id = $('#idbat').val();
$.ajax(
{
url:'index.php?r=site/vacancies',
data: {a:[name,number, age, exp, text, id]},
type: 'POST',
success: function (res) {
alert('Отклик на вакансию принят, после изучения ваших данных мы свяжемся с Вами. Сейчас произойдёт переадресация на главную страницу');
setTimeout( 'location="index.php?r=site/index";', 5);
console.log(res);
},
error: function () {
alert('Ошибка отправки');
}
}
);
return false; //запрет перенаправления
});