Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
This is MY WCF Method to return json
public string Employee_SelectDetails()
{
using (ISession session = nHibernateHelperClass.nHibernateHelperClass.OpenSession())
{
// Reteriving a value from sql using nHibernate
var users = session.CreateCriteria(typeof(Empdetails)).List();
// Using JSON to pass seriliza data to front end(MVC)
System.Web.Script.Serialization.JavaScriptSerializer objJSSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
string strJSON = objJSSerializer.Serialize(users);
return strJSON;
session.Flush();
session.Close();
Posted
Comments
F-ES Sitecore 16-Jun-15 8:49am    
You're going to need to give a bit more information. Are you calling this method from server code? From ajax? From both?

Also your session.Flush and session.Close methods are not being called, you need to place them before the "return"

1 solution

As said, use Flush and Close before return, otherwise it will not work.

1. Use a javascript method from click of the Employee name/id.
2. Use $.ajax or $.get/ $.Post as per your requirement. Do google for these option, you will get lot of examples.
3. Use your Json data in Success of this $.ajax method.
4. Have a empty div[display:none] and update this div with the data.

$('#divId').html(data);
$('#divId').show();

Here data is the Success event data.

You can have a partial view as well to append with JSON data.
 
Share this answer
 

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