0

i'm able to see the table result but in the image columm doesn't shows image, but if I load ajax_search_r.php or ajax_search_r.php directly I'm able to see the image..what happening when trying to render DATA returning,is the same echo code which I'm trying to load, cloud someone help me please ?

I have Jquery clik event that inside call

this the Main.PHP page and inside call this

 <body> 
    <div id="search"></div>
           ...
                $.post("../ajax/ajax_search_r.php",{criteria:criteria,value:value},function(data){
                                        $('#search').html(data);
            ...

this is my ajax_search_r.php

...
    while($row = mysqli_fetch_array($result))
    {
      echo "<tr>";
      echo "<td>" . $row['0'] . "</td>";
      echo "<td>" . $row['1'] . "</td>";
      echo "<td>" . $row['2'] . "</td>";
      echo "<td>" . $row['3'] . "</td>";
      echo "<td>" . $row['4'] . "</td>";
      echo "<td>" . $row['5'] . "</td>";
      echo "<td>" . $row['6'] . "</td>";
      echo "<td><img src=ajax_image.php?id=".$row['0']." width=160 height=120/></td>";   
      echo "</tr>";
    }
    echo "</table>";
...

and the ajax_image.php

...
    if($result)
    {
    $picture = mysqli_fetch_array($result);
    header('Content-Type: image/jpg');
    echo $picture['11'];
    }else
    echo "problem";
...
Jaiper
  • 1
  • 2
  • what does the returned data look like? do `console.log(JSON.stringify(data, null, 4))` and see what comes back. – Todd Dec 13 '14 at 14:14
  • I write console, but no let me choice log function try to write in function(data) { HERE } – Jaiper Dec 14 '14 at 00:18

1 Answers1

1

Seems like their are no quotes around the src url

   echo "<td><img src=ajax_image.php?id=".$row['0']." width=160 height=120/></td>"; 

   echo "<td><img src\"=ajax_image.php?id=".$row['0']."\" width=160 height=120/></td>"; 

or a combination of ' and "

Brett
  • 99
  • 5
  • Brett thank you for your awnser, but don't solve me the issue, the thing is that if I load(F12 dreamweaver) "ajax_search_r.php" directly I see the table and the image, but when I load Main.php that calls $.post() the $('#search').html(data); show me the table but not the image – Jaiper Dec 13 '14 at 18:19
  • Try to update your code to match http://stackoverflow.com/questions/900207/return-a-php-page-as-an-image note the .jpg extension and the content lenght – Brett Dec 13 '14 at 20:43