English 中文(简体)
在j Query使用php信息
原标题:Using php information in jQuery
  • 时间:2009-10-05 14:32:41
  •  标签:

我试图从《加拿大刑法》中获取一个变数,把它放在了格里,即试图这样做,任何人都无法帮助我?

< script type="text/javascript" src="js/jquery.query-2.1.6.js"></script>
<?
$next_exp = 123;
?>



 $(document).ready(function() {
 var next_exp = $.query.get( next_exp );
 $("#pb5").progressBar({ max: next_exp, textFormat:  fraction ,barImage:  images/progressbg_orange.gif  iii

iii

最佳回答

如果你需要制定非标准价值(例如阵列、物体或仅涉及任何东西),你可使用<代码>json_encode(:

<script type="text/javascript">
    <?php
        $next_exp = array(1, 2, 3);
        echo  var next_exp =   . json_encode($next_exp);
    ?>
    // next_exp is now a usable JavaScript array: [1, 2, 3]
</script>
问题回答

在你想要使用PHP$next_exp的地方,你需要这样做。

<?=$next_exp ?>

如果能够取得短信,或

<?php echo $next_exp; ?>

如果 short子残疾的话。

你们需要确定一种 j式变量,形成一种PHP变量:第一:

<?
echo("<script>");
echo("var next_exp=$next_exp");
echo("</script>");
?>

然后,你将能够在 Java稿中使用。 因此,你的整个例子就是这样:

<script type="text/javascript" src="js/jquery.query-2.1.6.js"></script>
<?
    echo("<script type= text/javascript >");
    echo("var next_exp=$next_exp");
    echo("</script>");
?>

<script type="text/javascript">
    $(document).ready(function() {
    $("#pb5").progressBar({ max: next_exp, textFormat:  fraction ,barImage:  images/progressbg_orange.gif  });
</script>




相关问题
热门标签