I have a select built on json and jquery but the data is concatenated
json
- public async Task
OnGetAssetAsync( string id) - {
- var assets = await _context.WOAssetAssets.Where(s => s.WOALId == id)
- .Select(s => new SelectListItem
- {
- Value = s.WOAId.ToString(),
- Text = s.AssetID + " " + "/" + " " + s.AssetName
- }).ToListAsync();
- return new JsonResult(assets);
- }
- $(function () {
- $("#Asset").on("change", function () {
- var categoryId = $(this).val();
- $("#Equipment").empty();
- $("#Equipment").append("");
- $.getJSON(`?handler=Equipment&id=${categoryId}`, (data) => {
- $.each(data, function (i, item) {
- $("#Equipment").append(``);
- });
- $('#Equipment').selectpicker({ liveSearch: true });
- });
- });
- });
json
- public async Task
OnGetAssetDetailsAsync( string id) - {
- var asset = await _context.WOAssetAssets.Where(s => s.WOAId == id).SingleOrDefaultAsync();
- return new JsonResult(asset.AssetName, asset.AssetManufacturer);
- }
- $(function () {
- $("#Asset").on("change", function () {
- var categoryId = $(this).val();
- $("#Equipment").empty();
- $("#Equipment").append("");
- $.getJSON(`?handler=Equipment&id=${categoryId}`, (data) => {
- $.each(data, function (i, item) {
- $("#Equipment").append(``);
- });
- $('#Equipment').selectpicker({ liveSearch: true });
- });
- $.getJSON(`?handler=AssetDetails&id =${categoryId}`, (data) => {
- $("#AssetName").append("asset.AssetName");
- $("#AssetManufacturer").append("asset.AssetManufacturer");
- });
- });
- });


Sachin SinghRank #66 · 26.2K reputationPosted Jan 30, 2021, 1:20 AM EST
Kiran MohantyRank #821 · 2.8K reputationPosted Jan 30, 2021, 12:44 AM EST
Marius VasileRank #785 · 2.9K reputationPosted Jan 30, 2021, 1:08 AM EST
Kiran MohantyRank #821 · 2.8K reputationPosted Jan 30, 2021, 1:13 AM EST
Marius VasileRank #785 · 2.9K reputationPosted Jan 30, 2021, 1:16 AM EST
Kiran MohantyRank #821 · 2.8K reputationPosted Jan 30, 2021, 1:25 AM EST
Marius VasileRank #785 · 2.9K reputationPosted Jan 30, 2021, 1:32 AM EST
Marius VasileRank #785 · 2.9K reputationPosted Jan 30, 2021, 12:50 AM EST
Marius VasileRank #785 · 2.9K reputationPosted Jan 30, 2021, 12:52 AM EST
Kiran MohantyRank #821 · 2.8K reputationPosted Jan 30, 2021, 1:04 AM EST