Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
jQuery POST
[HttpPost]
public ActionResult ConfirmLink(string id)
{
try
{
var confirmationMessage = SomeRepo.ConfirmLink(id);
return Json(new { confirmationMessage = confirmationMessage }, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
return new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message);
}
}
$.post(uri, postData)
.done(function (response) {
var confirmationMessage = response.confirmationMessage;
// Do something else.
})
.fail(function (response) {
console.log(response);
$('#error-message').html(response.statusText || "Could not link utility account.");
$('#error-modal').modal();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment