?

Log in

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

Buy 600+ Real Time Interview Videos

Call +91-22-66752917 or mail us on questpond@questpond.com for more details on C#, .NET, ASP.NET, SQL Server interview question videos.

SQL Server interview question videos

Latest Month

March 2017
S M T W T F S
   1234
567891011
12131415161718
19202122232425
262728293031 

Tags

Powered by LiveJournal.com