Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67411

How to display API data using Ajax?

$
0
0

I want to be able to use the API from the code below to display data in a formatted way such as this example.

Job Title: Agricultural and Related Trades

Percentage of Occupancies in Area: 15.41%

You can find my poor attempt to display the data below. I am very new to Ajax, jQuery, JavaScript, etc.

Thank you!

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
    $(function() {
        $.ajax({
        url: "http://api.lmiforall.org.uk/api/v1/census/jobs_breakdown?area=55.9895989531941,-3.796229726988194",
        type: "get",
        dataType: "json",
        success: function(data) {
            console.log(data[0].area);

            outputString= data[0].description.percentage;
            var paragraph = $("<p />", {
                text: outputString
            });

            $("body").append(paragraph);
        }
        });
    });
</script>

Viewing all articles
Browse latest Browse all 67411

Trending Articles