Basic API calls with JQuery

Basic API calls with JQuery

in API Development

Posted by: Tribio.8531

Tribio.8531

Hello everyone,

After reading a bit through the API documentation the urge to start programming reappeared on my side.. So I did some work today and yesterday and thought it’d be handy to share my code with you guys?

I believe very new API programmers might find it handy for reference, and I hope that advanced API experts might correct me or provide me with some nice comments..

Anyway, here she goes (all is in one .html-file)..

Attachments:

The Hatreidis family: Freya / Nina / Demonica / Athena / Faith / Arya / Angie / Sansa
Commander – Jam Death [Jd]
Fissure of Woe

Basic API calls with JQuery

in API Development

Posted by: ElGreenGo.6734

ElGreenGo.6734

That is a pretty good example of basic API use with jQuery. I would change a couple of things. You are using getElementById several places, since you are already using jQuery for the Ajax calls you could shorten document.getElementById(“some_id”).innerHTML=output; to $(“#some_id”).html(output);. Likewise, the $.ajax calls could be shortened and be made a little easier to read if you used the $.getJSON helper function instead.

Basic API calls with JQuery

in API Development

Posted by: Tribio.8531

Tribio.8531

Thank you for the feedback, much appreciated..
Indeed, the code needs to be optimalised some more (as you mention, use the JQuery functionality a bit more). Also I have to investigate some caching of the JSON-data, so that I don’t have to make constant API calls over Inet.. Work in progress, of course..
Ultimate plan is to get an overview like gw2thelazy for only my server (Fissure of Woe) where I can easily see the quest progress for the world bosses and our overall standing in WvW..

The Hatreidis family: Freya / Nina / Demonica / Athena / Faith / Arya / Angie / Sansa
Commander – Jam Death [Jd]
Fissure of Woe

Basic API calls with JQuery

in API Development

Posted by: Rawrfaec.6412

Rawrfaec.6412

Indeed, the code needs to be optimalised some more (as you mention, use the JQuery functionality a bit more).

Actually, using more jQuery will increase overhead. It takes quite a bit for that to be noticeable and the consistency can be worth more in the long run from a perspective of maintenance but raw JavaScript always outperforms jQuery. You certainly wouldn’t notice the difference in this case, however.

Basic API calls with JQuery

in API Development

Posted by: sorenrye.7238

sorenrye.7238

It has been some months now. Did you update the code in your links, fx wrt to local caching?

What is the status of your project?