There is a corner case where you need to know if jQuery is running on your page. Let’s say, you are using the ajaxForm plugin and that one of the input is of type “file.” ajaxForm will embed the call in a iFrame and the jQuery will not be included in it. So, for the page (or page fragment) that will be the target of such a call, you need to test if jQuery is running before running the script.
if (typeof($) != "undefined"){
$(document).ready(....
}
Unfortunately, ajaxForm does not support AJAX call in “text” only which would solve this problem.