Click here to Skip to main content
15,923,197 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to know which javascript frame work is best for web api in mvc.i am new in web api i want to start one of my project if we use jquery then what is the disadvantages using jquery?? please suggest me which one is good with web api in mvc...

What I have tried:

still i am just thinking which one is best for web api in mvc
Posted
Updated 15-Aug-16 22:27pm
v2

1 solution

Just use jQuery, it's practically an industry standard now and is well documented with lots of tutorials and code samples. The advantage is that it takes care of cross-browser issues for you and you have to write much less code than you would otherwise.
 
Share this answer
 
Comments
Kamar Shahzad 16-Aug-16 8:44am    
if i use jquery then how i communicate mvc view??basically i want to know if i use jquery then how i display data return from web api in mvc view??
F-ES Sitecore 16-Aug-16 9:05am    
You call an action and the action returns the View (normally a partial view). The MVC framework will cause that action to return the html which you can inject into the page. The alternative is that you return JSON from your actions and create elements in javascript from the data in that JSON and inject those elements into the DOM. eg if you return a product you can create a "div", in that div create a "p" and make the html of the "p" the title from the JSON, then add an "img" to the div and make the src of the image a url from the JSON, then inject the div into the page where you want the product to appear.
Kamar Shahzad 16-Aug-16 9:57am    
so basically when we are working in mvc action will return view along with data either list or object in web api only return json or xml,so when api return data we cant assign this to view or we cant return view with data in web api.if i use jquery then how this possible.??

example public actionresult index()
{
var data = context.product.get();
return view();
}
so in view i can get this data.
so how can i achieve this in web api? if i use jquery?? wep api only return me json data how to map this data with mvc view???
F-ES Sitecore 16-Aug-16 11:49am    
An mvc action can return html, or json, or pretty much anything. You can get web api to return html (google ".net webapi return view" and you'll find some ideas) but ideally webapi should only return data, so json or xml, and your calling code then works out what to do with that data and how to display it.

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