This code snippet is geared towards MVC 3 but is easily adaptable for whatever you are doing.
//Jquery using JSON to submit to the controller and its values
//Will Controller action will return either SUCCESS or FAILED and based on this
//you can display whatever message you'd like using a hidden div or div with no text
$("#IdOfElementOnPage").live("click", function(){
$.getJSON("@Url.Action("ActionName", "ControllerName")", {
val1: $("#TextBox").val(),
val2: $("#TextBox2").val()
}, function (data) {
if(data.returnmsg == "SUCCESS")
{
$("#DivWithNoText").html("Record Inserted Successfully");
}
else
{
$("#DivWithNoText").html("Something Blew Up");
}
});
});
public JsonResult ActionName(string val1, string val2)
{
string resultmsg = null;
if(x = 1)
{
resultmsg = "SUCCESS";
}
else
{
resultmsg = "FAILED";
}
return Json(returnmsg = resultmsg, JsonRequestBehavior.AllowGet);
}