I have very limited javascript experience and Im trying to modify the script below to show an alert of success or failure after the POST attempt:
<script language="javascript" type="text/javascript">
$(function() {
$("form").submit(function(e) {
$.post($(this).attr("action"),
$(this).serialize(),
function(data) {
$("#result").html(data);
});
e.preventDefault();
});
});
</script>
I know it needs to look like this:
success: function(){
alert("Edit successful");
},
error: function(){
alert('failure');
but cant figure out how to integrate it without syntax errors. This script is for performing the POST that the above code would normally perform to allow for this confirmation of success or failure to occur:
@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.one">
<span style="color:black">   Example:</span><span style="color:blue"> \\pathpart1\\pathpart2$\\</span>
<br>
<br>
<span style="font-weight:bold">SQL Connection String:</span>
<input type="text" name="sql_Connection" value="@ViewBag.two">
<span style="color:black">   Example:</span> <span style="color:blue"> Server=myserver;Database=mydatabase;Uid=myusername;Pwd=mypswd</span>
<br>
<br>
<button class="btn btn-success" type="submit" name="document">Save Changes</button>
</section>
</div>
}
ActionResult
public ActionResult Admin(string txt_file_dest, string sql_Connection)
{
AdminModel Values = new AdminModel();
if (txt_file_dest != null)
{
Values.SAVEtxtDestination(txt_file_dest);
}
if (sql_Connection != null)
{
Values.SAVEsqlConnection(sql_Connection);
}
ViewBag.one = Values.GetTextPath();
ViewBag.two = Values.GetSqlConnection();
return View();
}