title: Calling WebMethod returning IList<T> from Jquery Ajax with NHibernate And MVC
body: <p>I have a web method in My Controller...</p>
  
  <pre><code>    [WebMethod]
      public IList&lt;ThemeSelectList&gt; GetThemesForSelectedCategory(string themeCategoryId)
      {
          IList&lt;ThemeSelectList&gt; themeSelectList = new List&lt;ThemeSelectList&gt;();
          int emailLayoutThemeCategoryId = Convert.ToInt32(themeCategoryId);
          using (var trans = session.BeginTransaction())
          {
              EmailThemeBusinessLogic emailThemeBusinessLogic = new EmailThemeBusinessLogic(session, null);
              themeSelectList = emailThemeBusinessLogic.GetThemes(emailLayoutThemeCategoryId);
              trans.Commit();
          }
  
          return themeSelectList;            
      }
  </code></pre>
  
  <p>that i am trying to call from a java-script function, that is</p>
  
  <pre><code>function GetThemesForSelectedCategory(event)
  {
      event = event || window.event || e.srcElement;
      event.preventDefault();
      var selectedThemeCategoryId = $('#ddlThemeCategory option:selected').val();
      var ThemeContainerDiv = $("#ThemeContenerDiv");
      ThemeContainerDiv.html('&lt;p&gt;&lt;img src="../../../../Images/loading.gif"&gt;&lt;/p&gt;');
      $.ajax
      ({
          type: "POST",
          url: "GetThemesForSelectedCategory",
          data: JSON.stringify({ "themeCategoryId": selectedThemeCategoryId }),
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function (data) {
              // function is not returning to success
              var ThemeDetails = data.d;
              for (var i = 1; i &lt;= ThemeDetails.length; i++) {
                  var row = ['&lt;div id="' + ThemeDetails[i].ThemeId + '" class="themegroup divhighlight"&gt;\
                                  &lt;div class="themename"&gt;\
                                      ' + ThemeDetails[i].ThemeName + '\
                                  &lt;/div&gt;\
                                  ' + GetColourTamplate(ThemeDetails[i].ThemeTemplateColorList) + ''].join('\n');
              }
          },
          error: function (xhr, ajaxOptions, thrownError) {
              // always error method is getting called
              var somthing = "pankajDubey";
          },
          complete: function (data) 
          {
              var ThemeDetails = data.d;
              for (var i = 1; i &lt;= ThemeDetails.length; i++) {
                  var row = ['&lt;div id="' + ThemeDetails[i].ThemeId + '" class="themegroup divhighlight"&gt;\
                                  &lt;div class="themename"&gt;\
                                      ' + ThemeDetails[i].ThemeName + '\
                                  &lt;/div&gt;\
                                  ' + GetColourTamplate(ThemeDetails[i].ThemeTemplateColorList) + ''].join('\n');
              }
          }
      });
  }
  </code></pre>
  
  <p>i am unable to understand what is going wrong.
  Every Thing in web method is working fine but i don't know what is missing.
  please help as  I am new to MVC and NHibernate both...</p>