I am generating the list view via ajax. What i am trying to do is when user click it takes it to details view through its id. I am getting the list but not the details.My question is how to pass the id from page to another page.
$(document).ready(function(){
var output = $('#output');
$.ajax({
url: 'http://localhost/Backend/getDinner.php',
dataType: 'jsonp',
jsonp: 'jsoncallback',
timeout: 5000,
success: function(data, status){
$.each(data, function(i,item){
var Menu_Dinner = '<li><a data-transition="slide" href="details.html?ID='
+ item.ID + '">' +`'<img src="'+ item.ImageURL + '">' +
'<h2 class="ui-li-heading">' + item.Title + '</h2 >' +
'<h2>' + 'Price: ' + item.Price + '</h2>'+ '</a></li>';
output.append(Menu_Dinner);
console.log($("#output").html());`
});
},
error: function(){
output.text('There was an error loading the data.');
}
});
});
i used the code below to get the id from list view and display details of that specific list.
$('#detailsPage').live('pageshow', function(event) {
var ID = getUrlVars()["ID"];
$.getJSON(serviceURL + 'getDinner.php?ID='+ID, displayItem);
});
function displayItem(data) {
var item = data.item;
console.log(item);
$('#itemPic').attr('src', '' + item.ImageURL);
$('#fTitle').text(item.Title);
$('#Description').text(item.Description);
$('#Price').text(item.Price);
}
And this is the detail.html page that display the details .
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div id="detailsPage" data-role="page" >
<div data-role="header">
<a data-role="button" data-rel="back" data-icon="arrow-l" data-theme="b">Back</a>
<h1>Details</h1>
</div>
<div data-role="content">
<img id="itemPic"/>
<h3 id="Title"></h3>
<p id="Description"></p>
<p id="Price"></p>
<button class="add-to-cart">+ Add to Cart</button>
</div>
</div>
</body>
</html>