Sample code for Better way to handle ajax call in your code.