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

160
Views
Cómo cargar imágenes automáticamente usando PHP JSON

Soy nuevo en esto y agradecería si alguien me puede ayudar. El siguiente código lo uso para extraer textos de la base de datos mysql y funciona bien para obtener los datos sin actualizar la página. Lo que intento hacer ahora es hacer lo mismo con las imágenes almacenadas en la base de datos pero no se muestran.

 <?php include_once('db.php'); $sql = "SELECT * FROM images"; $res = mysqli_query($conn, $sql); $result = array(); while( $row = mysqli_fetch_array($res) ) array_push($result, array('image1' => $row['image1'])); echo json_encode(array("result" => $result)); ?>
 $(document).ready(function () { done(); }); function done() { setTimeout(function () { updates(); done(); }, 200); } function update_content() { $.getJSON("showImages.php", function (data) { $("#Imageslider").empty(); $.each(data.result, function () { $("#Imageslider"").append("<img" +this['image1'] + "/>"); }); setTimeout(function () { update_content(); }, 1000); }); }

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

demasiadas funciones

En el siguiente código, asumo que su PHP produce esto

 { "result" : [ { "image1":"someurl"},{ "image1":"someurl"}] }

Si es así, puedes hacer

 function update_content() { $.getJSON("showImages.php", function(data) { $("#Imageslider").html( data.result.map(({image1}) => `<img src="${image1}" />`).join("") ); setTimeout(update_content, 3000); // if you want to update the interface every 3 seconds }) } $(function() { update_content() })
about 4 years ago · Juan Pablo Isaza 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!