Skip to content

Instantly share code, notes, and snippets.

@jesslilly
Created January 5, 2015 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesslilly/d48058dd13f54218eac4 to your computer and use it in GitHub Desktop.
Save jesslilly/d48058dd13f54218eac4 to your computer and use it in GitHub Desktop.
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