Click here to Skip to main content
15,881,744 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hello guys,

i have one ajax function and into that i want bind html data with respect to result but problem is ...after i click button it goes to the post method and return
j- son object but coming to browser side it will gives internal server error (500)

i am really confuse that all the thing i put well even if it gives me this type of error

i put my code below


JavaScript
////Ajax function 

function ScrollDiv() {

              var st = $(this).scrollTop();
              var divScroll = false;
              if ($("#divGridCont").scrollTop() >= $("#grdLeadQueue").height() - $("#divGridCont").height() && divScroll == false) {
                  if (st >= lastScrollTop) {
                      divScroll = true;
                      var InnerHtml;
                      var vNxtCount = NxtCount;
                      var Search;
                      if (document.getElementById("txtSearch").value != "Enter your search here...") {
                          Search = document.getElementById("txtSearch").value.replace(/\s/g, encodeURIComponent(' '));
                      }
                      else {
                          Search = "";
                      }
                      var ParamData = { Searchstr: Search, NextCount: vNxtCount }
                      $.ajax({
                          url: '/Settings/TagSettings?NextCount=' + vNxtCount+'&Searchstr=' + Search,
                          dataType: "json",
                          type: "get",
                          contentType: 'application/json; charset=utf-8',
                          async: true,
                          success: function (result) {


                              $.each(result.Listfortag, function (j, dval)
                              {

                               var Tagname = dval.toString().split(",");
                               InnerHtml += "<tr>";
                               InnerHtml += "<td>" + Tagname[1] + "</td>";
                               InnerHtml += "<td>" + Tagname[2] + "</td>";
                               InnerHtml += "<td class=\"alignAction\">";
                               InnerHtml += "<a>";
                               InnerHtml += "<input type=\"button\" id=\"" + Tagname[0] + "\" onclick=\"EditDomain(id)\" class=\"edittbutton edittbuttonover\" style=\"cursor:pointer\">";
                               InnerHtml += "</a>";
                               InnerHtml += "<input type=\"button\" id=\"" + Tagname[0] + "\" class=\"deletbutton deletehover fltLeft\" style=\"cursor:pointer;\" onclick=\"ShowDeletePopup(id)\">";
                               InnerHtml += "</td>";
                               InnerHtml += "</tr>";
                             });

                              $('#grdLeadQueue tbody').append(InnerHtml);
                          },
                          error: function (xhr) {

                          }
                      });
                      NxtCount++;
                  }


              }
              lastScrollTop = st;

          }

/////c# method on controller side

 public ActionResult TagSettings(string Searchstr, int NextCount = 0)
        {
            try
            {
                #region Calculate take count

                int SkipCount = 0;
                int TakeCount = 0;
                int RowCount = 17;
                long Cnt = 0;

                if (NextCount == 0)
                {
                    TakeCount = 17;
                }
                else
                {
                    SkipCount = 17 + ((NextCount - 1) * RowCount);
                    TakeCount = (SkipCount + RowCount);
                    Cnt = SkipCount + 1;
                }

                #endregion Calculate take count

               
                vmTagSettings vmTag = new vmTagSettings();
                vmTag.lstTag = Tag.getSearchedTagByNameAndCount(TakeCount, SkipCount, "");
                vmTag.TagCount = vmTag.lstTag.Count;
                vmTag.lstTag = vmTag.lstTag.ToList();
                List<tag> lstTag = vmTag.lstTag;

           
              
               
                if (NextCount != 0)
                {
                    return Json(vmTag, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    return View(vmTag);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }</tag>
Posted
Updated 9-Jul-15 20:05pm
v3
Comments
Sergey Alexandrovich Kryukov 10-Jul-15 2:23am    
It's your server is "not working", not Ajax. So, essential part of relevant information is missing.
—SA
F-ES Sitecore 10-Jul-15 3:22am    
Use debugging and\or fiddler to find the specific error and go from there. We can't access your system so can't debug your code for you.

1 solution

It's the server error.Its nothing to do with the ajax function. So, first check your connection string in web.config file and try to give proper configuration like data source name, connection string name etc etc.
 
Share this answer
 
Comments
[no name] 10-Jul-15 6:20am    
hi ashish

i already tried all this thing also check data connection string but in the list i got the data but it cant bind into html

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