Ajax encapsulated

Ajax encapsulated into stubbed functions. Still buggy.