?

Log in

No account? Create an account

Previous Entry | Next Entry


Let’s assume you have a MVC controller action “getEmployee” which emits out employee JSON object as shown in the below code. Please note you can always emit JSON from any server technology like WCF , ASP.NET , MVC etc. Do read this link where we have discussed how we can emit JSON data using MVC and WCF. http://questpond.tumblr.com/post/32457322254/json-and-c-interview-questions-what-is-json

p1

To make a call to the above MVC action using Jquery  we need to use “getJSON” method. Below is the simple code for the same. It has three parameters:-

  1. The  first parameter is the URL which emits out JSON. For instance in the below code the URL is “/Employee/getEmployee”.

  2. The next parameter helps us to pass data to the resource which emits out JSON currently it’s the MVC action. Currently we are only doing  a get so the second parameter is NULL for now.

  3. The last parameter is the call back function which will be invoked once the MVC action returns data. You can see how the “getData” function just displays the “empcode” property. Because the output is in JSON it automatically converts the JSON data to javascript object.

p2
Copy right www.questpond.com

Tags

Latest Month

September 2017
S M T W T F S
     12
3456789
10111213141516
17181920212223
24252627282930
Powered by LiveJournal.com