Jquery引用php变量出错,如何解决?
如下:
<html>
<script type="text/javascript" src="js/jquery-min.js"></script>
<input type="button" value="submit" id="submit" />
<?php
$_stable='wo';
$year='2012';
echo <<<DRR
<script type="text/javascript">
var w=screen.width;
$("#submit").click(function(){
$.post("modules/auto.php",{action:"ac",stable:$_stable,year:$year},function(data){
});
});
//alert(w);
</script>
DRR;
?>
</html>
总是提示wo未定义,但是将$_table改成数字就没问题,什么原因,怎么解决?新手,谢谢
------解决方案--------------------$.post("modules/auto.php",{action:"ac",stable:'$_stable',year:$year},function(data){
------解决方案-------------------- PHP code
$.post("modules/auto.php",{action:"ac",stable:'$_stable',year:$year},function(data){
------解决方案--------------------
因为它是字符串 ,所以要加引号。