Let me explain the problem first, while I was working on my plugin I needed to insert the photo data into the database.
To do this I needed to use wordpress database functions, but the way I knew to use ajax(i.e. creating a separate php file which handles the ajax request), it was bit difficult and messy.
It would have involved either making a direct connection with the database or including the wordpress config file.
I was not happy with either of these options, I needed a simpler solution.
My Solution: admin-ajax.php and action hook wp_ajax_ can be used to keep your plugin simple.
Read rest of the article "Simplified AJAX For WordPress Plugin Developers using Jquery"