Why is the locations/ location data coming up as undefined in my table?
  • I don't know what i have done wrong? Can you help? my fuction is working and bringing me back the: title, summary and company, but for the rest it just says undefined in my table?
    this is my function:

    function getVacancies() {
    var Postcode = $("#Postcode-input").val();
    var searchtitle = $("#search-input").val();
    var apiurl = "http://api.lmiforall.org.uk/api/v1/vacancies/search?postcode=";
    var apicall = apiurl + Postcode + "&keywords=" + searchtitle;
    $.get(apicall, function(data) {
    $("#Vacancies tbody").html("");
    $.each(data, function(i, e) {
    var tablerow = $("");
    tablerow.append("" + e.title + "");
    tablerow.append("" + e.summary + "");
    tablerow.append("" + e.company + "");
    tablerow.append("" + e.city + "");
    tablerow.append("" + e.area + "");
    tablerow.append("" + e.postcode + "");
    tablerow.append("" + e.country + "");
    $("#Vacancies tbody").append(tablerow);
    });
    });
    }

    and this is mt table:


    Vacancies in your Area




    Title Summary Company City Area Postcode Country


  • PhilippRustemeier
    LMIForAll Team Accepted Answer
    Hi,

    you probably want e.location.city, e.location.area and so on instead of e.city and e.area. It's one level deeper inside the object.

    Edit: it helps if you try out stuff in the API explorer and check out what the returned data looks like!

    http://api.lmiforall.org.uk/#!/vacancies/search
  • Thanks, that worked perfectly, and i am using the api but i didn't know about the depth of the object stuff

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook Sign In with Google Sign In with OpenID