Click here to Skip to main content
15,949,741 members

Comments by klein_jnr (Top 7 by date)

klein_jnr 12-Dec-13 8:16am View    
I need attributes like Dog Food,Rand,Distance to belong to one Shopname:Shoprite and all the other details to another SHopName :spar it like Shopname:Shoprite has to be a parent container to Name,Rand,Distance and SHopname:Spar has to be a parent container to Name,Rand,Distance too
klein_jnr 12-Dec-13 7:06am View    
This only shows one results in other words it only returns one array this is what it returns ShopName :Shoprite
Name : DogFood
Rand :150
Distance in Km :8309559.355265908 and does not return the secound one like this(reults that are not displayed ) ShopName :Spar
Name : DogFood
Rand :100
Distance in Km :16471269.62219214 i need to return both these results but they shouldnt be clustered first result must alone and visa versa
klein_jnr 12-Dec-13 6:37am View    
Okay thank you so much here there working code
function GetProductDetails(barcodeId,coords)
{
$.getJSON("api/products/?barcodeId=" + barcodeId + "&latitude=" + coords.latitude + "&longitude=" + coords.longitude)
.done(function (data) {
$('#result').append(data.message)
console.log(data)
var list = $("#result").append('<ul></ul>').find('ul');
$.each(data.results, function (i, item)
{


if (data.results == null) {

$('#result').append(data.message)
}

else {


list.append('<li>ShopName :' + item.retailerName + '</li>');
list.append('<li>Name : ' + item.productName + '</li>');
list.append('<li>Rand :' + item.price + '</li>');
list.append('<li>Distance in Km :' + item.Distance + '</li>');


}

});

$("#result").append(ul);

});
}
klein_jnr 12-Dec-13 3:51am View    
Thank you so much Talip, i managed to display everything the way you told me to go about like this. Product Details
Thank you for shopping with us details will be sent to you shortly
ShopName :Shoprite
Name : DogFood
Rand :150
Distance in Km :8309559.355265908
ShopName :Spar
Name : DogFood
Rand :100
Distance in Km :16471269.62219214 but now i need to to separate the list in two parts for readabilty purposes, so that if there are many shops that have the searched product the shopname with all the other items will be added but they should be grouped together i tried the </br> tags but just makes spaces between each item and dont make spaces between two groups, your help is appriciated i am very new to all this
klein_jnr 12-Dec-13 2:07am View    
Thank you Tadit no i dont see my data on my console and i would also like to know how i would iterate or go through each object while using the code that you showed me because my data result object is an array of 2 using something like $.each(data, function (key, item) and i only see undefined appearing on my html page as my list,Thank you for your help