Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
Pasar una variable a una llamada Ajax

Estoy usando el siguiente código para rotar y guardar una imagen almacenada en el servidor.

 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript" src="http://beneposto.pl/jqueryrotate/js/jQueryRotateCompressed.js"></script> <img src="uploads/101822973264163759893-1428320267361.jpeg" id="img"/> <script> $(document).ready(function(){ var value = 0 $("#img").rotate({ bind: { click: function(){ value +=90; $(this).rotate({ animateTo:value}) } } }); $(document).on('click', '#img', function() { // alert("Hello"); var idno = "test"; $.ajax({ url: "saveimage.php", dataType: "html", type: 'POST', data: "panelid="+idno, //variable with data success: function(data){ // $(".test").html(data); // alert(data); } }); }); }); </script>

guardarimagen.php

 <?Php $degrees = -90; //change this to be whatever degree of rotation you want header('Content-type: image/jpeg'); $filename = 'uploads/101822973264163759893-1428320267361.jpeg'; //this is the original file $source = imagecreatefromjpeg($filename) or notfound(); $rotate = imagerotate($source,$degrees,0); imagejpeg($rotate,$filename); //save the new image imagedestroy($source); //free up the memory imagedestroy($rotate); //free up the memory ?>

Encontré este código aquí: http://www.codehaven.co.uk/rotate-and-save-an-image-using-php/ .

Todo esto funciona bien, pero estoy tratando de pasar una variable de PHP que contiene la ruta de la imagen y el nombre de la llamada ajax y no tengo idea de cómo hacerlo.

¿Alguien puede ayudar?

Gracias,

John

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede pasar la variable como parámetros de URL:

 url: "saveimage.php?path=/folder/to/your/image/&image=image_name",

Puede usar urlencode para asegurarse de que todos los caracteres especiales se transfieran

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!