I'm working on a website that, among other things, have items with prices that are pulled from "outside" on controller level. Controller then returns the Json object to the Ajax complete function and one of the properties is supposed to replace the content of a certain html element.
This is the Ajax call:
$('.price').each(function (i, e) {
var id = $(e).attr('name');
var exterior = $(e).attr('title');
$.ajax({
type: "GET",
url: "/Skin/GetPrice",
data: { Id: id, Exterior : exterior },
cache: false,
dataType: "json",
}).complete(function (data) {
if(data.responseJSON.success)
{
var val = data.responseJSON.lowest_price;
$(e).html(""); //this works and DOES clear the content of the element
$(e).html(val); // this does NOT work
$(e).html(data.lowest_price); // this also doesn't work - returns "undefined"
$(e).html(data.responseJSON.lowest_price); // this also doesn't work
$(e).attr('title', 'Steam Market price for ' + exterior);
$(e).removeClass('loading-cube');
$(e).addClass('padding10');
}
});
});
I am 100% sure that I'm getting the object properly, besides data.responseJSON.success
checks properly.
I have no idea why this is happened, but I'm sure there's an easy fix for this that I'm not aware of..
here's the return command in the controller:
return Json(new { success = true, lowest_price = data["lowest_price"].ToString() });
HTML:
<div class="cell">
<a href="#" class="price block full-size loading-cube" name="@Model.Skin.Id" title="@e.Name">Fetching...</a>
</div>