Getting value from json object in jquery ajax call and replacing div content with a property from the object
<p>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.</p>

<p>This is the Ajax call:</p>

<pre><code>$('.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');
        }
    });
});
</code></pre>

<p>I am 100% sure that I'm getting the object properly, besides <code>data.responseJSON.success</code> checks properly.</p>

<p><a href="https://i.stack.imgur.com/WTD3O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WTD3O.png" alt="enter image description here"></a></p>

<p>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..</p>

<p>here's the return command in the controller:</p>

<pre><code>return Json(new { success = true, lowest_price = data["lowest_price"].ToString() });
</code></pre>

<p>HTML: </p>

<pre><code>&lt;div class="cell"&gt;
    &lt;a href="#" class="price block full-size loading-cube" name="@Model.Skin.Id" title="@e.Name"&gt;Fetching...&lt;/a&gt;
&lt;/div&gt;
</code></pre>