Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this code is not working properly all the thing in .Net code is ok and SQL Query is ok but the issues in JQuery code because i use multiple table in datalist but this is not properly handle in JQuery. Kindly Help

XML
<head id="Head1" runat="server">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

    <script type="text/javascript">
        var pageIndex = 1;
        var pageCount;
        $(window).scroll(function () {
            if ($(window).scrollTop() == $(document).height() - $(window).height()) {
                GetRecords();
            }
        });
        function GetRecords() {
            pageIndex++;
            if (pageIndex == 2 || pageIndex <= pageCount) {
                $("#loader").show();
                $.ajax({
                    type: "POST",
                    url: "CS1.aspx/GetFollowersData",
                    data: '{pageIndex: ' + pageIndex + '}',
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: OnSuccess,
                    failure: function(response) {
                        //alert(response.d);
                    },
                    error: function(response) {
                        //alert(response.d);
                    }
                });
            } GetFollowersData
        }
        function OnSuccess(response) {
            var xmlDoc = $.parseXML(response.d);
            var xml = $(xmlDoc);
            pageCount = parseInt(xml.find("PageCount").eq(0).find("PageCount").text());
            var Followers = xml.find("Followers");
            var table = $("#dvFollowers table")
            Followers.each(function () {
                var Follower = $(this);
                var row = $("#dvFollowers table tr").eq(0).clone(true);
                $(".UserName", row).html(Follower.find("RowNumber").text());
                $(".FirstName", row).html(Follower.find("Reg_No").text());
                $(".LastName", row).html(Follower.find("Reg_Curr_Code").text());
                $(".Country", row).html(Follower.find("PostedOn").text());
                table.append(row);
            });
            $("#loader").hide();
        }
    </script>

</head>
<body>
    <form id="form1" runat="server">
        <div id="dvFollowers">
            <asp:DataList Width="100%" ID="DataListFollowers" runat="server">
<ItemTemplate>
<table><tr><td><%# Eval("RowNumber") %></td></tr></table>
<table><tr><td><%# Eval("Reg_No")%></td></tr></table>
<table><tr><td><%# Eval("Reg_Curr_Code")%></td></tr></table>
<table><tr><td><%# Eval("PostedOn")%></td></tr></table>

                </ItemTemplate>
            </asp:DataList>
            <img id="loader" alt="" src="103.gif" style="display: none" />
        </div>
    </form>
</body>
</html>
Posted
Updated 6-Jun-15 3:17am
v6
Comments
ZurdoDev 6-Jun-15 21:51pm    
You haven't said what the problem is or where you are stuck.
ksmtariqzafar 7-Jun-15 15:18pm    
The issue is that when I use datalist without table in its itemtemplate so the result is ok but when I use multiple tables to make a design of page so it doesn't work properly.
ZurdoDev 7-Jun-15 17:03pm    
And what does "doesn't work properly mean?"
ksmtariqzafar 8-Jun-15 1:04am    
means: like i have data from 1 to 100 and i want to display the data 10 rows at a time
1
2
3
4
5
6
7
8
9
10
scrolling down....
11
12
13
14
15
16
17
18
19
20
scrolling down....
21
22
.
.
but when i scroll 1st time the data appear just first row in series like this

1
2
3
4
5
6
7
8
9
10
scrolling down....
1
1
1
1
1
1
1
1
1
scrolling down....
1
1
1
1
1
.
.
.
.
this is happen when i set the design in the Data list item template using multiple tables in it like this

<itemtemplate>
<table><tr><td><%# Eval("RowNumber") %></td></tr></table>
<table><tr><td><%# Eval("Reg_No")%></td></tr></table>
<table><tr><td><%# Eval("Reg_Curr_Code")%></td></tr></table>
<table><tr><td><%# Eval("PostedOn")%></td></tr></table>



but when i remove all the table with in the item template then the result is ok.
xszaboj 8-Jun-15 5:27am    
Did you solved it? I think it might be problem in your OnSuccess method. Could you please provide me the html code of your page? I am interested in this div:
<div id="dvFollowers">

with table and correct + wrong rows

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