On click of a button, I want to delete something from my database.
The following is my click handler.
$('.deleteLesson').click(function () {
$.get('/Assignment/Modules/DeleteLesson.cshtml?LessonID=' + lessonID,function(data){
});
});
Inside DeleteLesson.cshtml, I have the following
var db = Database.Open("database");
db.Query("DELETE FROM Lessons WHERE LessonID=@0", Request.QueryString["LessonID"]);
When the $.get
runs, the SQL is performed on my database, but it forces a refresh on my original page. I can't figure out why. Through troubleshooting I have discovered it is purely the db.Query
line that causes the refresh, and nothing else.
To be clear: I can comment out the db.Query line and it works exactly as I want it to (except it doesn't delete the item)
I don't know whether to laugh or cry... it turns out my live.js
was forcing the refreshes as it saw changes and wanted to update the page for me. (As intended, I just never expected it to do it in these circumstances).
Thanks for the help everyone...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With