如何通过函数将MySQL数据从PHP传递给Javascript

I'm making a program that shows several descriptions taken from a database (MySQL):

echo "<input type=\"submit\" id=\"Boton" . $i . "\" value=\"Mostrar Descripcion\""
                                            . " onclick=cambiarBoton(" . $i . ", \"" . $row["descripcion"] . "\") />";

echo "<div class=\"entrada-descripcion\" id=\"Descripcion" . $i . "\">  </div>";

where $row["descripcion"] is the access to the description and $i is an identifier because i'm using loops. That code generates a button that i must press to show the description. The javascript function "cambiarBoton" is the one that do that changes:

function cambiarBoton(i, d){

                    if (document.getElementById("Boton"+i).value == "Mostrar Descripcion"){
                        document.getElementById("Boton"+i).value = "Ocultar Descripcion";
                        document.getElementById("Descripcion"+i).innerHTML = d;
                    }else if(document.getElementById("Boton"+i).value == "Ocultar Descripcion"){
                        document.getElementById("Boton"+i).value = "Mostrar Descripcion";
                        document.getElementById("Descripcion"+i).innerHTML = "";
                    }

                }

Ok, but there is a problem in the program and this is that i can't pass the description to the function in javascript and this doesn't works. How can i do this? (I must do this without using AJAX)

The problem was in the call of the function "cambiarBoton" in the code PHP, it should have been this:

echo "<input type=\"submit\" id=\"Boton" . $i . "\" value=\"Mostrar Descripcion\""
                                        . " onclick=\"cambiarBoton(" . $i . ", '" . $row["descripcion"] . "')\" />";

And then it works.

I answer to the question I think you're asking is:

<?php echo "<script>var data = ".$row["description"].";</script>"; ?>