I haven't reproduced your problem, can you provide the relevant code for your request api?
I wrote an example, you can refer to it.
Model
public class PaymentModel
{
public long PaymentId{ get; set; }
public string PaymentReceiver{ get; set; }
public string PersonNme { get; set; }
public int UniqueId { get; set; }
public decimal Amt { get; set; }
}
Controller
public PaymentModel GetPaymentById(long id)
{
PaymentModel test = new PaymentModel
{
PaymentId = 208637836008,
Amt = Decimal.Parse("260.50"),
PaymentReceiver = "BENDAHARI UNIVERSITI TKNOLOGI MARA",
PersonNme = "NURUL NASUHA BINTI ZAHARI",
UniqueId = 0
};
return test;
}
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
success: function (data) {
$("#tabeltest tbody").empty();
$.each(data, function (key, value) {
$("#tabeltest tbody").append("<tr><td>" + key + ":</td><td> " + value + "</td></tr>");
});
}
Best Regards,
YihuiSun
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Has your previous problem been solved?I suggest you could mark the answer which is helpful. This will help other people who faces the same issue to find the right answer faster.
Best Regards,
YihuiSun
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
Has your previous problem been solved?I suggest you could mark the answer which is helpful. This will help other people who faces the same issue to find the right answer faster.
Best Regards,
YihuiSun
Hi YihuiSun,
I need help on jQuery side. The Web API always return 1 row only. Can you show me,
How jQuery request Web API and paste the value using Label tag?
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
You can put the js code in $( document ).ready(function() {}); so that the code contained in it will
runas soon as the entire page is loaded.
Note:
I set a breakpoint in the browser (open with F12) to show you how to add data to the page (use
F10 to execute step by step). You can view the animation below to better help you understand.
ASP.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today. Learn more >
What did you expect? There are 4 fields. In the loop you set these files to the loop item values, or course they will be the values of the last item in the loop.
Member
223 Points
305 Posts
Need help write jQuery request Web API Data
Sep 08, 2020 10:46 PM|bonusnet|LINK
I'm jQuery Newbies. I've Web API URL & Data as following,
Web API need (1) Query String Parameter named - id. Let's say, id=2018637836008. My html as below,
How to replace ???, ???, ??? with appropriate value based Web API Parameter?
Please help
Contributor
2990 Points
857 Posts
Re: Need help write jQuery request Web API Data
Sep 09, 2020 08:00 AM|YihuiSun|LINK
Hi bonusnet,
Model
Controller
View
Here is the result.
Best Regards,
YihuiSun
Member
223 Points
305 Posts
Re: Need help write jQuery request Web API Data
Sep 09, 2020 08:10 AM|bonusnet|LINK
Hi Yishun,
I need help as following,
Please help
Contributor
2990 Points
857 Posts
Re: Need help write jQuery request Web API Data
Sep 10, 2020 01:54 AM|YihuiSun|LINK
Hi bonusnet,
<table class="table table-bordered" id="tabeltest"> <thead></thead> <tbody></tbody> </table>
Best Regards,
YihuiSun
Member
223 Points
305 Posts
Re: Need help write jQuery request Web API Data
Sep 10, 2020 01:56 AM|bonusnet|LINK
Hi YihuiSun,
I made new posting. Can you help me at - https://forums.asp.net/t/2170601.aspx?Need+help+on+Entity+Framework
Please help
Contributor
2990 Points
857 Posts
Re: Need help write jQuery request Web API Data
Sep 10, 2020 02:03 AM|YihuiSun|LINK
Hi bonusnet,
Has your previous problem been solved?I suggest you could mark the answer which is helpful. This will help other people who faces the same issue to find the right answer faster.
Best Regards,
YihuiSun
Member
223 Points
305 Posts
Re: Need help write jQuery request Web API Data
Sep 10, 2020 02:28 AM|bonusnet|LINK
Hi YihuiSun,
I need help on jQuery side. The Web API always return 1 row only. Can you show me,
How jQuery request Web API and paste the value using Label tag?
Please help
Contributor
2990 Points
857 Posts
Re: Need help write jQuery request Web API Data
Sep 10, 2020 05:42 AM|YihuiSun|LINK
Hi bonusnet,
Here is the result.
Best Regards,
YihuiSun
Member
223 Points
305 Posts
Re: Need help write jQuery request Web API Data
Sep 10, 2020 06:13 AM|bonusnet|LINK
Hi YihuiSun,
Yes. Every jQuery send parameter ( id ), it only return 1 row of data. PaymentId | PaymentReceiver | PersonNme | Amt
This return, how jQuery assign in PAGE LOAD. Your sample is button click. I need sample in PAGE LOAD
Please help
Contributor
2990 Points
857 Posts
Re: Need help write jQuery request Web API Data
Sep 10, 2020 08:47 AM|YihuiSun|LINK
Hi bonusnet,
You can put the js code in $( document ).ready(function() {}); so that the code contained in it will run as soon as the entire page is loaded.
Note:
Best Regards,
YihuiSun
Member
223 Points
305 Posts
Re: Need help write jQuery request Web API Data
Sep 11, 2020 04:42 AM|bonusnet|LINK
Hi YihuiSun,
I follow your code and make it few amendment. Here the result,
Looks like, it's not paste in accurate <div> statement. Web API is fine
Need help adjust jQuery Loop
Member
223 Points
305 Posts
Re: Need help write jQuery request Web API Data
Sep 13, 2020 07:56 AM|bonusnet|LINK
Please help
All-Star
58444 Points
15769 Posts
Re: Need help write jQuery request Web API Data
Sep 13, 2020 07:33 PM|bruce (sqlwork.com)|LINK
What did you expect? There are 4 fields. In the loop you set these files to the loop item values, or course they will be the values of the last item in the loop.
Member
223 Points
305 Posts
Re: Need help write jQuery request Web API Data
Sep 14, 2020 06:57 AM|bonusnet|LINK
Frankly speaking, I really don't know - How the jQuery syntax looks like. So far, I've this
Unfortunately, no value return
Please help