I am trying to learn ajax but I dont know how to do this. When I click on the map the function called “region()” will be running as well as the ajax inside. From the console i got response from the ajax call, it is a numeric data. But I dont know how to return back the response to the variable “boosting”
var boosting = <?php echo($difference)?>;
var produk = $("select[name='produk']").val();
function region(province) {
var kfas = province.split(' ').join('_');
var produk = $("select[name='produk']").val();
var url_get = '<?php echo site_url('boosting/call_rekomendasi_data/')?>'+kfas+'/'+ produk;
$.ajax({
url: url_get,
type: 'GET',
error: function() {
alert('Something is wrong with recomendation');
},
success: function(data) {
console.log(data);
boosting.update(data);
}
});
#here i am trying to return back the value into variable “boosting”