Implementing ajax method