Created
January 5, 2015 20:11
-
-
Save jesslilly/d48058dd13f54218eac4 to your computer and use it in GitHub Desktop.
jQuery POST
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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