2017-07-07 2 views

Antwort

0

einfach echo die img Quelle aus der Datenbank.

<?php 
    if(isset($_POST['profile_id'])){ 
    var uid=$_POST['profile_id']; 
    $result->query("SELECT profile FROM user WHERE uid=$uid"); 
    $row=$result->fetch_array(); 
    die(json_encode($row)); 
    } 
?> 

HTML:

<a href="#" class="pop"> 
    <img src="" style="width: 400px; height: 264px;"> 
</a> 

JQuery Teil:

$.post("ajax.php",{profile_id:1},function(response){ 
    if(response){ 
    var profileImg=JSON.parse(response); 
     profileImg=profileImg[0].profile; 
     $('.pop img').attr('src','http://example.com/image/'+profileImg); 
     $('.pop').modal('show'); 
    } 
}); 
+0

Sarath weiß, dass ich den PHP-Teil. Ich möchte wissen, wie Bilder in Modal mit Jquery und Bootstrap angezeigt werden. – JayV

+0

@JayV siehe aktualisierte Antwort –