Half-baked - API check added

Add API validity check (Our first jquery/ajax)
Refactored some API query functionality