Click here to Skip to main content
15,898,938 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am trying to send data to controller and return back allowGet using $.post(url {String:string } fucnction(){}) method , But not get success ,jqury did not hit url in controller
please help me .

What I have tried:

jquery code


$(document).ready(function () {
    $('#orderdetailsItems').on('click', '.remove', function () {
            var isAllValid = "";
            var $Srrmv = $(this).closest("tr").find(".sr") .val();   
            if ($Srrmv == "0") {
                isAllValid = false
                alert("not Get")
            }
            else {
                isAllValid = true;
            }
            if (isAllValid) {
                var $tot = $(this).closest("tr") .find(".Total").val();
                var Pnet = $("#NetTotal").val();
                var n_result1 = "";
                if ($tot !== "" && $.isNumeric($tot) && $.isNumeric(Pnet)) {
                    n_result1 = parseFloat(Pnet) - parseFloat($tot);
                }
                var URL = "/Credit/Removeline";
                var Srno = $(this).closest("tr").find(".sr").val().trim();
               
                if (Srno != null) {
                    alert(Srnor + "Post Methode") 
                     // he show this alert msg then no response//

                    $.post(URL, { Srno: Srno }, function (data) {
                         $(this).parents('tr').remove();
                       alert("Srno" + $Srrmv + "    REMOVE SUCCESSFULLY ");
                    });
                }

               
            }
    });
});


in a Credit controller

[HttpPost]
        public JsonResult Removeline(Dport pd, int Srno, int PerTranCode) {

            var rmv = dc.PerchesDetails.Where(m => m.PerTranCode == PerTranCode).ToList();
             
            return Json(pd, JsonRequestBehavior.AllowGet);
        }
Posted
Comments
Bryian Tan 23-Feb-19 0:41am    
the jQuery only posting 1 parameter, but look like the Action is expecting 3.
sayli1995 23-Feb-19 1:49am    
sir , int PerTranCode is a public verifiable and it's have a value , Dport pd .. Dport is database table and going to remove data from this table and parameter is srNo and PerTranCode
sayli1995 23-Feb-19 5:28am    
Thanks sir , after add a parameter PerTranCode to jquery i got a result ,
once again thanks sir ,
Bryian Tan 23-Feb-19 15:03pm    
Anytime

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900