1

I've been having trouble accessing this piece of content in a json object. Here is my code for fetching data:

function getEntries(key){
 $.ajax({
 url: "https://openlibrary.org/api/books?bibkeys=ISBN:" + key + "&jscmd=details&callback=mycallback",
 dataType: "jsonp",
 success: function(data){
 console.log(data);
 }
 });
 }

The reply I get looks like this: enter image description here

How do I access the pointed object if the key is different for every search?

asked Jan 21, 2017 at 15:46
2
  • data.ISBN not working ? Commented Jan 21, 2017 at 15:49
  • No, but I found out that data.["ISBN:" + key ] does... Commented Jan 21, 2017 at 15:50

2 Answers 2

1

Try using

data["ISBN:"+key]

Where key is the key you are passing to the function

answered Jan 21, 2017 at 15:50
Sign up to request clarification or add additional context in comments.

Comments

0

I think I found it after all...

function getEntries(key){
 $.ajax({
 url: "https://openlibrary.org/api/books?bibkeys=ISBN:" + key + "&jscmd=details&callback=mycallback",
 dataType: "jsonp",
 success: function(data){
 console.log(data["ISBN:"+key]);
 }
 });
 }

did the trick.

answered Jan 21, 2017 at 15:50

2 Comments

So maybe use the extra 3 minutes to think it over before posting the question? ;-)
You wouldn't believe me if I told you that I've been banging my head over this for the last 20 minutes. The answer flashed right after I clicked post.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.