Replaced xmlhttprequest with $.ajax