here is My code.when I activate below code via wordpress custom plugin,It shows 'var' (T_VAR), error . error:- Parse error: syntax error, unexpected 'var' (T_VAR),expecting end of file in /var/www/wptbox/wp-content/plugins/...... on line ,var data = "";
help me to resolve it. I found this similar answer (PHP parse/syntax errors; and how to solve them I can't get real answer.
var data = "";
$(document).ready(function() {
getHealthData();
});
/**
*Gets data from API
**/
function getHealthData() {
$.ajax({
type: "GET",
dataType: "json",
url: "https://www.hpb.health.gov.lk/api/get-current-statistical",
data: {
action: "get_data"
},
success: function(response) {
//getting value from server
var value = response.data;
data = "<h5>local_total_cases :</h5><b>" + value['local_total_cases'] + "</b><br/><h5>local_deaths :</h5><b> " + value['local_deaths'] + "</b><br/><h5> local_new_deaths : </h5><b>" + value['local_new_deaths'] + "</b><br/><h5>local_recovered : </h5> <b>" + value['local_recovered'] + "</b><br/><h5>local_new_cases :</h5> <b>" + value['local_new_cases']+"</b>";
//putting values in div with id="data"
$("#data").html(data);
//adding value separately
$("#something").text("local_total_cases :" + value['local_total_cases'])
}
});
}