If you are talking about a form strictly,and if you can use a javascript framework, such as jQuery, it would gives you all the AJAX functionalities your are looking for, in no time:
See http://api.jquery.com
You can check this question:
jQuery AJAX submit form
Which gives you a way to do it. You could also improve your code to make it more accessible and less obstructive (which makes it a lot more easier to support, since javascript would be separated from your html code).
<button id = "graph" >my action</a>
and in your head, in a script element:
$(document).ready(function() {
// the functions below are executes once the document is loaded
$("#graph").click(function(){
validation('graph','D');
});
});
If you do not talk strictly about a form, you can do it by defining uri and handler:
http://www.domain.com/?r=my-action/arg1/arg2/arg3...
There are commons techniques you will find in a Model View Controller frameworks (I do not no which server langage you are working with).
Note: there are others framework than jQuery, but I am used to it
http://en.wikipedia.org/wiki/Comparison_of_JavaScript_frameworks