I am trying to get the image stored in db as json and diplay the image using javascipt. but not able to view the image. i tried fire bug to view the html code img src is showing null.
here is my php code to get the data from db table:
<?php
header('Content-type: application/json');
include 'connect.php';
$b_id=$_GET['b_id'];
$c_id=$_GET['c_id'];
$sql_select=mysql_query("SELECT * FROM business_directory WHERE business_category_id=$b_id") or die(mysql_error());
$records = array();
if(mysql_num_rows($sql_select)>0){
while($row=mysql_fetch_array($sql_select)){
$records[] = $row;
}
echo $_GET['jsoncallback'] . '(' . json_encode($records) . ');';
}else{
echo 'data not selected';
}
?>
Here is javascript code:
function get_business(){
$.ajax({
url:'http://localhost/ajax_practice/php/get_business.php',
dataType: 'jsonp',
jsonp: 'jsoncallback',
timeout: 5000,
success:function(data){
$.each(data, function(i,item){
var output="";
$(".gallery").append(output);
output+="<li>";
output+="<a href='category.html?b_id="+item.id+"' data-transition='slide' rel='external'>";
output+="<img src='"+item.business_icon+"'/>";
output+="<span>"+item.business_name+"</span";
output+="</a>";
output+="</li>";
$(".gallery").append(output);
});
}
});
}
Can onyone help me that how can i get the data from database and show it using javascript.