javascript - How can I get some data from jQuery and call Html.ActionLink with it -


i have hidden html.actionlink, "delete" - action name, "students" - controller name:

@html.actionlink("delete student", "delete", "students", new { id = "" }, new { @id = "deletebutton", @style = "visibility:hidden;" }) 

and jquery code:

<script type="text/javascript">     $(document).ready(function () {         var table = $('#students_table').datatable();          $('#btndelete').click(function () {             var studentid = table.row('.selected')[0]; //this give me correct id             //alert(studentid);              if (studentid) {                 var href = "?id=" + studentid;                 //$("#deletebutton").attr(href).click();                 //$('#deletebutton').attr("?id=" + encodeuricomponent(studentid)).click();             }             table.row('.selected').remove().draw(false);         });      }); </script> 

my problem in calling actionlink id got ($("#deletebutton").attr(href).click();)

p.s. #btndelete - id simple button in html

do delete ajax:

<script type="text/javascript">     $(document).ready(function () {         var table = $('#students_table').datatable();          $('#deletebutton').click(function (event) {             event.preventdefault();              var studentid = table.row('.selected')[0]; //this give me correct id             //alert(studentid);              if (studentid) {                 $.get( "url_to_backend?id=" + studentid, function() {                     table.row('.selected').remove().draw(false);                 });             }         });     }); </script> 

http://api.jquery.com/jquery.get/


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -