the previous response is ASP.NET only
you need a reference to jquery (perhaps from a CDN): http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1.js
and then a similar block of code but simpler...
$.ajax({ url: '/Controller/Action/Id',
success: function(data) { alert(data); },
statusCode : {
404: function(content) { alert('cannot find resource'); },
500: function(content) { alert('internal server error'); }
},
error: function(req, status, errorObj) {
// handle status === "timeout"
// handle other errors
}
});
I've added some necessary handlers, 404 and 500 happen all the time if you are debugging code. Also, a lot of other errors, such as timeout, will filter out through the error handler.
ASP.NET MVC Controllers handle requests, so you just need to request the correct URL and the controller will pick it up. This code sample with work in environments other than ASP.NET