Marius Vasile

Marius Vasile

  • 594
  • 1.9k
  • 144.7k

asp.net core send two parameters to json procedure

Mar 17 2021 1:20 PM
I have a tabulated view with data provided from a json. I send one parameter for query and I want to send two parameters. How do I do that?
 
 
  1. <ul class="nav nav-tabs" role="tablist" id="myTab">  
  2.         @{int i = 0;  
  3.             foreach (var item in Model.WOPlannerL.OrderBy(s => s.WONumberS))  
  4.             {  
  5.                 if (i == 0)  
  6.                 {  
  7.                     <li class="nav-item">  
  8.                         <a class="nav-link active" data-toggle="tab" href="url/@item.WOMainID" data-Id="@item.WOMainID" data-target="#@item.WOMainID">@item.WONumber - @item.WONumberS</a>  
  9.                     </li>  
  10.                 }  
  11.                 else  
  12.                 {  
  13.                     <li class="nav-item">  
  14.                         <a class="nav-link" data-toggle="tab" href="url/@item.WOMainID" data-Id="@item.WOMainID" data-target="#@item.WOMainID">@item.WONumber - @item.WONumberS</a>  
  15.                     </li>  
  16.                 }  
  17.                 i++;  
  18.             }  
  19.         }  
  20.     </ul>  
 
  1. public async Task<JsonResult> OnGetCraftAsync(string id)  
  2.         {  
  3.             var woplanner = await _context.WOPlanners.FirstAsync(s => s.WOMainID == id);  
  4.             return new JsonResult(woplanner);  
  5.         }  
 
 
  1. <script>  
  2.         $(function () {  
  3.             $(".nav-link").on("click", function () {  
  4.                 var categoryId = $(this).attr("data-Id");  
  5.   
  6.                 $.getJSON(`?handler=Craft&id=${categoryId}`, (data) => {  
  7.                     $("#planner").html(data.planner);  
  8.                     $("#activity").html(data.activity);  
  9.                     $("#parts").html(data.parts);  
  10.                     $("#partsA").html(data.partsAvailable);  
  11.                     $("#tools").html(data.tools);  
  12.                     $("#toolsA").html(data.toolsAvailable);  
  13.                     $("#expertise").html(data.expertise);  
  14.                     $("#expertiseA").html(data.expertiseAvailable);  
  15.                     $("#sops").html(data.sops);  
  16.                     $("#sopsA").html(data.sopsAvailable);  
  17.                     $("#costs").html(data.costs);  
  18.                     $("#craft").html(data.craft);  
  19.                 });  
  20.             });  
  21.         });  
  22.     </script>  

Answers (6)