Acquiring and formatting data from a JSON file I have a JavaScript function that is getting data out of a JSON file and then doing some formatting to it.  The code works but I feel like it just an awful way of doing it.  All criticism and help appreciated.

function MCScrap(ZWA, ZWB, ZWC, ZWD, Number) {

$(document).ready(
        function() {
            setInterval(function() {



                $.getJSON("mccount.json", function(machines) {
                    console.log(machines);
                    var Tcount = machines.Machines[Number].Tcount;
                    var Ycount = machines.Machines[Number].Ycount;
                    var TScount = machines.Machines[Number].TScount;
                    var YScount = machines.Machines[Number].YScount;
                    document.getElementById(ZWA).innerHTML = Ycount;
                    document.getElementById(ZWB).innerHTML = Tcount;
                    document.getElementById(ZWD).innerHTML = TScount + "%";
                    document.getElementById(ZWC).innerHTML = YScount + "%";
                    if (TScount &lt; 3) {
                        document.getElementById(ZWB).style.backgroundColor = 'lime';
                    } else if (TScount &lt; 5) {
                        document.getElementById(ZWB).style.backgroundColor = 'orange';
                    } else {
                        document.getElementById(ZWB).style.backgroundColor = 'red';
                    }

                    if (YScount &lt; 3) {
                        document.getElementById(ZWA).style.backgroundColor = 'lime';
                    } else if (YScount &lt; 5) {
                        document.getElementById(ZWA).style.backgroundColor = 'orange';
                    } else {
                        document.getElementById(ZWA).style.backgroundColor = 'red';
                    }
                }
                );

            }, 3000);
        });
}
I'd suggestion cleaning it up like this:

function MCScrap(ZWA, ZWB, ZWC, ZWD, Number) {
    $(document).ready(function () {
        setInterval(function () {
            $.getJSON("mccount.json", function (machines) {
                var zwa, zwb, zwc, zwd, TScount, YScount;

                zwa = document.getElementById(ZWA);
                zwb = document.getElementById(ZWB);
                zwc = document.getElementById(ZWC);
                zwd = document.getElementById(ZWD);

                zwa.innerHTML = machines.Machines[Number].Ycount;
                zwb.innerHTML = machines.Machines[Number].Tcount;

                YScount = machines.Machines[Number].YScount;
                zwc.innerHTML = YScount + "%";
                TScount = machines.Machines[Number].TScount;
                zwd.innerHTML = TScount + "%";

                function getColor(count) {
                    if (count &lt; 3) {
                        color = 'lime';
                    } else if (count &lt; 5) {
                        color = 'orange';
                    } else {
                        color = 'red';
                    }
                    return color;                
                }

                zwa.style.backgroundColor = getColor(YScount);
                zwb.style.backgroundColor = getColor(TScount);

            });

        }, 3000);
    });
}


Types of changes:


Get a DOM element once into a variable and then use it from there rather than calling document.getElementById() more than one for the same DOM element.
Put the color code into a reusable function rather than having two copies which also makes it easier to set the color in just one place rather than three places.
Put zwa, zwb, zwc, zwd blocks of code in order to make it easier to read and follow.




Some other things that seem a little off to me:


Putting $(document).ready() inside another function like this seems a little odd.  Usually, you would call MCScrap() inside a $(document).ready() as that would make your function a bit more reusable.
Setting up an ajax call to run every 3 seconds in perpetuity is generally not a good idea.  For starters, it's horrible for battery life (phone, tablet, laptop).  And, it can get messy if you every get in a situation where the ajax call takes longer than 3 seconds to finish or timeout.  Then, you have multiple ajax calls in flight at the same time and they could be building up.  The safer way to do this is to launch the next ajax call from a setTimeout() that is set in the completion of the previous ajax call.  Then, they can never build up.