Use a variable from php in a js file

0

I have the following problem I have a variable that contains the path of an image in the database I need to send this variable with the path to a js file, but until I found several scripts with examples of how to bring this variable the problem is like I'll use it in a function, follow the code:

  

crop.php file

<?php
$sQuery=mysql_query("SELECT * FROM feridas WHERE ferida_id = $id_ferida");
$row_s = mysql_fetch_object($sQuery);
$img_caminho = "../" . $row_s->ferida_path;
$img_destino = "upload/" . $id_ferida . ".png";
$_SESSION["img_ferida"] = $row_s->ferida_path;
?>
<script type="text/javascript"> var param = "<?php echo $img_destino ?>";> </script>
<script type='text/javascript' src='../include/cropmaster/crop.js'> </script>
  

File crop.js:

//Funçao que traz a variavel php
jQuery(document).ready(function(){
var pagina = param;
jQuery('#btnpaginas').click(function(){
    pagina++;
    var dados = jQuery( this ).serialize();
    jQuery.ajax({
        type: "POST",
        url: "crop.php?pagina="+pagina,
        data: dados,
        success: function(data)
        {
            $(".paginacao").html(data);
        }
    });
    return false;
});    

});

//funçao para fazer um crop na imagem
$(document).ready(function() {
var condition = 1;
var points = [];//holds the mousedown points
var canvas = document.getElementById('myCanvas');
this.isOldIE = (window.G_vmlCanvasManager);
$(function() {
  //  if (document.domain == 'localhost') {

        if (this.isOldIE) {
            G_vmlCanvasManager.initElement(myCanvas);
        }
        var ctx = canvas.getContext('2d');
        var imageObj = new Image();
        function init() {
            canvas.addEventListener('mousedown', mouseDown, false);
            canvas.addEventListener('mouseup', mouseUp, false);
            canvas.addEventListener('mousemove', mouseMove, false);
        }
        // Draw  image onto the canvas
        imageObj.onload = function() {
            ctx.drawImage(imageObj, 0, 0);
        };
        imageObj.src = "dados"; 

// imageObj.src = get variable coming from php

    
asked by anonymous 16.01.2018 / 22:57

0 answers