Do something like the following. This is using JQUERY
jQuery.ajax({
type: "POST",
url: "/index.php",
data: "tmpl=ajax",//in templates/system/ I create a file called ajax, which is a view. All my php goes there
success: function(response){
alert(response);
},
error: function(er){
alert("error! "+er);
return false;
}
});