debugging and $.ajax()

* added a debug flag for displaying/not displaying debug output
* adjusted all console.log() statements to use debug()
* added in use of $.ajax() in order to catch parser errors, which is microsoft’s
  way of returning api call exceptions