This may not be directly applicable, but you might want to look at DBIx::Timeout. It kills a running MySQL query when a timeout is reached - you could use the same technique but have it trigger off an AJAX request.
-sam
Comment on Re: Cancel DBI Mysql request in a CGI script called with XMLHTTPREQUEST