public ActionResult DeleteItem(int pid) { //my logic goes here retutn View("SomeView",model); }
script type="text/javascript"> $(document).ready(function () { $('.Remove').click(function () { var value = $(this).attr('id'); $.ajax({ cache:true, type: "POST", url: "@(Url.Action("DeleteItem", "ControllerName"))", data: "pid=" + value, success: function (data) { $("body").html(data); }, error:function (xhr, ajaxOptions, thrownError){ alert('Failed to subscribe.'); }, complete: function() { } }); return false; }); }); </script>
Quote: script type="text/javascript"> $(document).ready(function () { $('.Remove').click(function () { var value = $(this).attr('id'); $.ajax({ cache:true, type: "POST", url: "@(Url.Action("DeleteItem", "ControllerName"))", data: "pid=" + value, success: function (data) { var t=$(data).find('.divtoreplacewith'); $('.divtoreplace').replaceWith(d); //Wasted my 2 days for above two lines.But satisfied with solution, //Both div are same but '.divtoreplacewith' is having new data,And I have replaced div with that div that's all }, error:function (xhr, ajaxOptions, thrownError){ alert('Failed to subscribe.'); }, complete: function() { } }); return false; }); });
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)