Uncaught ReferenceError: canceled is not defined at deposit_list.php:40

Uncaught ReferenceError: canceled is not defined at deposit_list.php:40

var x = <?php echo $row['type'];?>;
    if (x=="canceled") {
        document.getElementById("3").selected = "true";
    }else if (x=="pending") {
        document.getElementById("1").selected = "true";
    }else if (x=="succeed") {
        document.getElementById("2").selected = "true";
    }else{

    }
<th><select id="select">
             <option value="1" id="1">Pending</option>
             <option value="2" id ="2">Succeed</option>
             <option value="3" id="3">Canceled</option>
</select></th>

当我 运行 上面的代码.. 我得到错误 Uncaught ReferenceError: canceled is not defined at deposit_list.php:40。在 40 没有。它表示 <option value="2" id ="2">Succeed</option> 行。我无法理解为什么会这样?

尝试使用“

var x = "<?php echo $row['type'];?>";