Using jquery to check if POST is successful
asp.net-mvc, html, jquery
Solution
So I figured out my answer. Just for future reference to anybody that tries this, below is what I did. I placed it above @using (Html.BeginForm("Admin", "Home", "POST")). @Andrew I did try yours, but I could not get it to work. Thanks to everyone for tyring to help me.
<script language="javascript" type="text/javascript">
$(function() {
$("form").submit(function(e) {
$.post($(this).attr("action"), // url
$(this).serialize(), // data
function (data) { //success callback function
alert("Edit successful");
}).error(function () {
alert('failure');
});
e.preventDefault();
});
});
</script>
Problem
I am trying to write jquery function that will pop up and say Post was successful! and if not, Post was not successful! How could I use a try catch with inputting some jquery? ``` @using (Html.BeginForm("Admin", "Home", "POST")) { <div class="well"> <section> <br> <span style="font-weight:bold">Text File Destination:   </span> <input type="text" name="txt_file_dest" value="@ViewBag.GetTextPath"> <span style="color:black">   Example:</span><span style="color:blue"> \\invincible\\chemistry$\\</span> <br> <br> <span style="font-weight:bold">SQL Connection String:</span> <input type="text" name="sql_Connection" value="@ViewBag.GetSqlConnection"> <span style="color:black">   Example:</span> <span style="color:blue"> Server=-</span> <br> <br> <button class="btn btn-success" type="submit" >Save Changes</button> </section> </div> ``` }