我在单引号中写了值数据并希望添加var值但是当我看到它在out中时它显示为put
<a onclick="getCompanyRatesGraph(103, " all',="" '%');'="">%</a>
//Out put should be like this
<a onclick="getCompanyRatesGraph(103, 'all', '%');">%</a>
任何人都可以帮我解决这个问题,这是我编写的代码,用于显示链接
function getCompanyRatesGraph(val, timeFrame) {
$('.load_dt_grph').show();
$.ajax({
url : "<?php echo site_url('company/'.$companies['id']); ?>",
type : "POST",
dataType: "json",
data : "id=" + val + "&timeFrame=" + timeFrame,
success : function (data) {
if (timeFrame === "day") {
make_chart(data);
} else {
make_chart(data);
}
var companies_id = ]<?php echo $companies['id'] ?>";
var data_per = "<a onclick='getCompanyRatesGraph('"+companies_id+"', '"+timeFrame+"', '%');'>%</a>";
$('.per').html(data_per);
$('.pkr').html('<a onclick="getCompanyRatesGraph(<?php echo $companies['id'] ?>, "'+timeFrame+'", "Pkr");">Pkr</a>');
if(data.length < 1) {
$(".amcharts-chart-div").html("<h3 style='text-align: center;'>Today's Data is not available.</h3>");
}
$('.load_dt_grph').hide();
}
});
}
所以我的问题在这里提出我在这里做错了我没有正确起诉报价
答案 0 :(得分:1)
试试这个
var companies_id = "<?php echo $companies['id'] ?>";
var data_per = "<a onclick=\"getCompanyRatesGraph("+companies_id +",'"+timeFrame+"', '%');\">%</a>";
这将有效
答案 1 :(得分:0)
可能你可以试试这个:
var companies_id = "<?php echo $companies['id'] ?>";
data_per = "<a onclick='getCompanyRatesGraph('"+companies_id+"', '"+timeFrame+"', '%');'>%</a>";
$('.per').html(data_per);