function randomsituation() {
    var rand = Math.floor(Math.random() * 4);
    switch (rand){
        case 0:
            situation = "<td><p id=p2>&nbsp;</p></td><td>Online</td>"
            break;
        case 1:
            situation = "<td><p id=p1>&nbsp;</p></td><td>Offline</td>"
            break;
        case 2:
            situation = "<td><p id=p3>&nbsp;</p></td><td>Offline mais de 1 dia</td>"
            break;
        case 3:
            situation = "<td><p id=p4>&nbsp;</p></td><td>instalar</td>"
            break;
        default:
            break;
        }
    return situation;
}


var request_url = "http://209.126.111.4:8084/getListNameOfVehicles";

var dados =[{"vehicleCode":1},{"vehicleCode":2},{"vehicleCode":3},{"vehicleCode":4},
{"vehicleCode":5},{"vehicleCode":6},{"vehicleCode":7},{"vehicleCode":9}]; 



    $.ajax({

        url : request_url,

        data: {codigos_veiculos: JSON.stringify(dados)},

        dataType : 'json',

        error : function(erro) {
            console.log("requestCampaigns >> erro");
            console.log(JSON.stringify(erro));
            alert(erro.error);
        },

        success : function(response) {
            myFunction(response);
        },

        complete : function() {
            console.log("requestCampaigns >> complete request.");

        },

        type : "POST"

    });

function myFunction(arr) {

    var i;
    var out = "<table>";

    out += "<tr><th>ID</th><th>Nome</th><th>Cidade</th><th>Estado</th><th colspan = 2>Situação</th></tr>"

    for(i = 0; i < arr.length; i++) {
        out += "<tr><td>" +
        arr[i].vehicleCode +
        "</td><td>" +
        arr[i].fantasyName +
        "</td><td>" +
        arr[i].city +
        "</td><td>" +
        arr[i].state +
        "</td>" +
        randomsituation() +
        "</tr>"
   }
    out += "</table>";
    document.getElementById("id01").innerHTML = out;

  
}