asp.net mvc - <a> click event not firing from jquery -


i have requirement update data without redirecting page. in controller have method return type of void updates data. in partial view have <a> element. on click of link calling above method returns void jquery file.

<div id="footer">     <a href="#" id="markallread">mark read</a> </div> 
$(".markallread").click(function () {     alert('click');     $.ajax({         url: "/controller/marknotification",         method: 'post',         cache: false,         datatype: "text",         success: function (result) {             $("#ncount").hide();         },         error: function (xhr) {             alert(result.responsetext);         }     }); }); 
public void marknotificationasread() {     db.notifications.tolist().foreach(n => n.status = true);     db.savechanges(); } 

the problem facing ajax call not getting fired. on click of link want call above method returns void jquery file.

i think have error in jquery selector.

$(".markallread").click(function () { 

should become this: (use # instead of dot - dot class nd # id)

$("#markallread").click(function () { 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -