Heres my set up. I have a button.
<input type="submit" value="Checkout" name="submitAction" class="btn btn-block alert-success unlock" />
That hits this controller.
[HttpPost]
public ActionResult CheckoutCase(int id)
{
Case currentCase = db.Cases.Find(id);
currentCase.LockCase = true;
currentCase.Lockout_TS = DateTime.Now;
LogHistory userComments = new LogHistory("Case has been checked out", "User");
currentCase.LogHistories.Add(userComments);
db.SaveChanges();
string url = this.Request.UrlReferrer.AbsolutePath;
return Redirect(url);
}
At the same time when that button is clicked I'm trying to run a 15 minute jquery timer that will let the user know that their session has expired and hit another controller that unlocks the case here.
[HttpPost]
public ActionResult UnlockCase(int id)
{
Case currentCase = db.Cases.Find(id);
currentCase.LockCase = false;
string url = this.Request.UrlReferrer.AbsolutePath;
return Redirect(url);
}
I've tried many different things with JQuery but I cant seem to find the right way to make this work.
$('.unlock').click(function(){
setTimeout(function () {
var id = @Model.ID
$.ajax({
type: 'POST',
url: '/Case/UnlockCase',
data: 'id=' + id,
success: function () {
window.location.reload(true);
}
});
//}, 15 * 1000 * 60);
}, 10000);
}
Error:
Use of getPreventDefault() is deprecated. Use defaultPrevented instead. browserLink:37:0 Use of nsIFile in content process is deprecated. filesystem.js:38:0 TypeError: this._recipeManager is null LoginManagerParent.jsm:185:9 Use of getPreventDefault() is deprecated. Use defaultPrevented instead. browserLink:37:0 Handler function threw an exception: TypeError: info is null Stack: _addBreakpoint@resource://gre/modules/commonjs/toolkit/loader.js -> resource:///modules/devtools/sourceeditor/debugger.js:138:5 addBreakpoint/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource:///modules/devtools/sourceeditor/debugger.js:154:37 makeInfallible/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/DevToolsUtils.js:83:14 Line: 138, column: 5 DevToolsUtils.js:59:0 Key event not available on some keyboard layouts: key="e" modifiers="accel alt" debugger.xul Key event not available on some keyboard layouts: key="v" modifiers="accel alt" debugger.xul Key event not available on some keyboard layouts: key="f" modifiers="accel alt" debugger.xul Key event not available on GTK2: key="u" modifiers="shift, accel" toolbox.xul
Any help would be much appreciated.