Callback function in jquery doesn't seem to work......

Posted by Pandiya Chendur on Stack Overflow See other posts from Stack Overflow or by Pandiya Chendur
Published on 2010-03-31T07:30:13Z Indexed on 2010/03/31 7:53 UTC
Read the original article Hit count: 282

Filed under:
|

I use the following jquery pagination plugin and i got the error a.parentNode is undefined when i executed it...

<script type="text/javascript">
        $(document).ready(function() {
            getRecordspage(1, 5);
            $(".pager").pagination(17, { callback: pagechange,
                current_page: '0', items_per_page: '5', num_display_entries
: '5', next_text: 'Next', prev_text: 'Prev', num_edge_entries: '1'
            });
        });


        function pagechange()
        {
                $("#ResultsDiv").empty();
                $("#ResultsDiv").css('display', 'none');
                getRecordspage($(this).text(), 5);
        }

function getRecordspage(curPage, pagSize) {
    $.ajax({
        type: "POST",
        url: "Default.aspx/GetRecords",
        data: "{'currentPage':" + curPage + ",'pagesize':" + pagSize + "}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(jsonObj) {
            var strarr = jsonObj.d.split('##');
            var jsob = jQuery.parseJSON(strarr[0]);
            var divs = '';
            $.each(jsob.Table, function(i, employee) {
                divs += '<div class="resultsdiv"><br /><span class="resultName">' + employee.Emp_Name + '</span><span class="resultfields" style="padding-left:100px;">Category&nbsp;:</span>&nbsp;<span class="resultfieldvalues">' + employee.Desig_Name + '</span><br /><br /><span id="SalaryBasis" class="resultfields">Salary Basis&nbsp;:</span>&nbsp;<span class="resultfieldvalues">' + employee.SalaryBasis + '</span><span class="resultfields" style="padding-left:25px;">Salary&nbsp;:</span>&nbsp;<span class="resultfieldvalues">' + employee.FixedSalary + '</span><span style="font-size:110%;font-weight:bolder;padding-left:25px;">Address&nbsp;:</span>&nbsp;<span class="resultfieldvalues">' + employee.Address + '</span></div>';
            });
            $("#ResultsDiv").append(divs).show('slow');
            $(".resultsdiv:even").addClass("resultseven");
            $(".resultsdiv").hover(function() {
                $(this).addClass("resultshover");
            }, function() {
                $(this).removeClass("resultshover");
            });
        }
    });
}


</script>

and in my page,

<div id="ResultsDiv" style="display:none;">

</div>
<div id="pager" class="pager">

</div>

Any suggestion....

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about callback