亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將值從php文件發送到js文件

將值從php文件發送到js文件

PHP
慕后森 2023-10-15 15:24:08
我想將值從 php 傳遞到 js 文件,像這樣的代碼但不工作有什么問題嗎?謝謝php 文件$var = 10;<script>var phpVar = "<?php echo json_encode($var) ?>;";</script><script type="text/javascript" src='vendor/circliful/circliful.custom.js'></script>js 文件$("#overallProgress").circliful({        animationStep: 5,        foregroundBorderWidth: 12,        backgroundBorderWidth: 6,        percent: 'alert(phpVar);', **<-- place value from php**        fontColor: '#000000',        foregroundColor: '#1a8e5f',        backgroundColor: 'rgba(0, 0, 0, 0.1)',//      icon: '\eab4',        iconColor: '#1a8e5f',        iconPosition: 'middle',//      text: 'Statistik',        textBelow: true,        animation: 1,        animationStep: 1,        start: 2,        showPercent: 1,         });抱歉,我在 php 中有錯誤代碼,這是正確的代碼<?php$var = 67;?><script>var phpVar = <?php echo json_encode($var) ?>;</script><script type="text/javascript" src='vendor/circliful/circliful.custom.js'></script>
查看完整描述

1 回答

?
繁花如伊

TA貢獻2012條經驗 獲得超12個贊

Alert 是一個顯示消息框的 JavaScript 函數,也不能用單引號括起來,只需添加 phpvar 變量并測試

percent: phpVar,


查看完整回答
反對 回復 2023-10-15
  • 1 回答
  • 0 關注
  • 107 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號