将常量php打印到jQuery中

I have a page where I have to print a constant php into jQuery. Now if I print returns me an error: "SyntaxError: missing ; before statement" Because my text contains space anbd i don't want to cancel that space! Here is my code (I have tried with serialize and trim before but same error)

<script type="text/javascript">
$(document).ready(function(){

    $(".menu_an").click(function() {
        var txt = $(this).attr("id");
        var temp=<?php echo titolo_antilope; ?>;
        alert(temp);
        //$('#descrizione').text(<?php echo titolo_antilope ?>);
    });
});
</script>

<body>

                <div class="animale">
                    <div class="firstColAni">
                       <p class="txt_14 menu_an" style="cursor:pointer;" id="antilope">Antilope</p>
                       <p class="txt_14 menu_an" style="cursor:pointer;" id="bisonte">Bisonte</p>
                    </div>
                    <div class="secondColAni">
                       <p class="txt_14 menu_an" style="cursor:pointer;" id="descrizione"></p>
                    </div>
                </div>

Try this...

Now temp is a string value in Javascript need to enclose in double quote.

<script type="text/javascript">
$(document).ready(function(){

    $(".menu_an").click(function() {
        var txt = $(this).attr("id");
        var temp= "<?php echo $titolo_antilope; ?>";
        alert(temp);
        //$('#descrizione').text(<?php echo $titolo_antilope ?>);
    });
});
</script>

I guess $ sign missing for titolo_antilope;

Its a php variable, right?

I guess you have missed double quotes . try this

<script type="text/javascript">
$(document).ready(function(){

    $(".menu_an").click(function() {
        var txt = $(this).attr("id");
        var temp= "<?php echo titolo_antilope; ?>";
        alert(temp);
        //$('#descrizione').text(<?php echo titolo_antilope ?>);
    });
});
</script>
var temp='<?php echo titolo_antilope; ?>';