Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
i can not pass parameters to backend ( from Ajax to IActionResult or JsonResult) .net core 5

i have problem i can't pass params to backend use fech or ajax call , but from another PC i can pass params, here is a sample from code

Backend :

    [HttpPost]
    public IActionResult SubProducat(int Pid)
    {
        List<Lookup> SubProducat = new BAL.Lookups.LookupBL().SubProducatByProduct(Pid);
        return Json(SubProducat);
    }

** Here the Pid always zero **

JavaScript Code:

   $.ajax({
                async: false,
                type: "POST",
                url: '@Url.Action("GetSubProducat", "Notification")',
                data: JSON.stringify({ Pid: $("#ProducatId").val() }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var returnedData = $.parseJSON(data);
                    $('#SubProducatId').empty();
                    $('#SubProducatId').append("<option value='' selected>---Select---</option>");
                    $.each(returnedData, function (key, value) {
                        $('#SubProducatId').append(
                            '<option value="' + value.ID + '">'
                            + value.NameEN +
                            '</option>');
                    });
                },
                error: function (Edata) { alert(Edata); }
            }); 
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try the below code

$.ajax({
   type: "POST",
   url: '@Url.Action("SubProducat", "ControllerName")',
   data: $("#ProducatId").val() ,
   contentType: "application/x-www-form-urlencoded",
   dataType: "json",
   success: function (data) {
        ...
   },
   error: function (Edata) { alert(Edata); }
}); 
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!