1

My client has a jobs board whose API data I'm pulling via Ajax. I can parse the "jobs" data but cannot seem to pull any thing else. For instance, this works to pull the names of job listings to a select box:

$.ajax({
    url:'https://api.greenhouse.io/v1/boards/roivantsciences/jobs/',
    type:'GET',
    data: 'q=' + "",
    dataType: 'json',
    success: function( json ) {
        $.each(json.jobs, function(i, value) {
            $('#myselect').append($('<option>').text(value.title).attr('value', value.title));
        });
    }
});

But when I change "json.jobs" to anything else like "json.offices" or "json.locations" nothing is pulled. How do I go about accurately targeting these data strings to cull together for a complete careers page? Appreciate any guidance whatsoever thanks.

This is the JSON if you need to take a look:

https://api.greenhouse.io/v1/boards/roivantsciences/jobs/
4
  • I dont see offices or locations object in given json Commented Jun 29, 2017 at 15:00
  • Sorry meant "location". Commented Jun 29, 2017 at 15:02
  • 1
    try $.each(json.jobs, function(i, value) { $('#myselect').append($('<option>').text(value.location).attr('value', value.location)); }); Commented Jun 29, 2017 at 15:04
  • Thanks. It's still pulling the job names not the locations... Commented Jun 29, 2017 at 15:06

2 Answers 2

1

try pull location.name for all jobs $.each(json.jobs, function(i, value) { $('#myselect').append($('<option>').text(value.location.name).att‌​r('value', value.location.name)); });

Sign up to request clarification or add additional context in comments.

1 Comment

Thats great. It works but now its pulling every instance of each location, e.g.: it's pulling New York as an <option> multiple times. How would I go about consolidating them into groups, perhaps with an integer indicating the number of jobs in each (e.g: "New York (6 jobs)") . Thanks again, clearly I'm extremely new to this...
0

Ive done a small test:

$.ajax({
url:'https://api.greenhouse.io/v1/boards/roivantsciences/jobs/',
type:'GET',
data: 'q=' + "",
dataType: 'json',
success: function( json ) {
   console.log(json)
}

});

What I got back from console is that your json object only has 'jobs' as the top attribute in it.

You have to go through it like this to get locations:

 $.each(json.jobs, function(i, value) {
        console.log(value.location);
    });

then you have the location object inside this you got the attribute 'name'

so u can get the names with value.location.name

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.