My JSON:
[{
"i_id":"1",
"i_name":"Biryani",
"i_category":"Pakistani",
"i_Uploader_Name":"Nabeel",
"i_dateofadd":"2016-01-24",
"i_rate":"0",
"image_name":"Biryani-main1.jpg",
"image_path":"images\/Biryani-main1.jpg",
"image_thumb":"thumb\/Biryani-main1.jpg"
}]
I want to give to every recipe its different id, so that I can show them anywhere:
 $('#btnsearchres').click(function(){
            $("#recipes").empty();
            var content;
            var ingredient=$('#txtsearch').val();
            //$server = 'http://localhost/XDK';     
 $.getJSON(server+"/search.php",{ingredient:ingredient},function(data){
    $.each(data, function(i,data){
    content='<ul data-role="listview" data-inset="false" data-theme="a">';
    content += '<li><a>' + data.i_category + '</a></li>';
    content += '<li><a href="#"><img src="http://localhost/xdk/'+data.image_thumb+'" style="width:200px;height:200px;"/>';
        content+='<h3>'+data.i_name+'</h3>';
    content += '<p overflow: hidden; text-overflow: ellipsis;white-space: nowrap;">' + data.i_recipe + '</p></a></li>';
        content+='<li><input id="btn'+data.i_id+'" onclick="ViewItem('+data.i_id+','+UserId+')" type="button" value="View" style="padding-top:10px;"/></li>';
        content+='</ul><hr>';
    $(content).appendTo("#recipes");
    });
});
});
It is my ViewItemFunction. But when I press on view, it does nothing:
 function ViewItem(ItemId,UserId){
    alert("working");//not working
    var content;
    $.ajax({
                           type: "post",
                           dataType  : 'html',
                           url: $server+"/view.php",
                           data: {ItemId:ItemId,UserId:UserId},
                           success: function(result) {
                               alert(result);
                               
                                $(content).appendTo("#");
                            }
                       });
}
 
     
     
    