Ajax request not working .

Ajax request not working .

Niranjan12345Niranjan12345 Posts: 3Questions: 1Answers: 1

I have implemented server side pagination ,and it is working only for the first request but not for subsequent requests. My requirement is such that ,when page loads, data is loaded, which is working fine. When user clicks a button again ithe data should be loaded from the url, which is not working, Ajax request is not being triggered.

My code

$(document).ready(function(){
$('#imgLoad').css('display', 'block');
$( "#India" ).prop("checked", true)

    var curDate = getdate();        
    theme(curDate,"XXX");

function theme(dateSet,type) {

     $('#table').
        DataTable( {
             "processing": true,
             "serverSide": true,
             retrieve: true,
             bRetreive:true,


             "ajax":{
                 "url": "/rest/themes/es/all",
                 "data":{"date":dateSet,"type":type}

             },


             "drawCallback" : function(settings) {

                $('#imgLoad').css('display',
                'none');
            },


            /*
            "fnInfoCallback": function( oSettings, iStart, iEnd, iMax, iTotal, sPre ) {
                   index =iStart

                 return iStart +" to "+ iEnd + " " + "of"+" " +iTotal + " " + "Records" 


              },
              */

            "fnRowCallback" : function(nRow,
                    aData, iDisplayIndex,
                    iDisplayIndexFull) {

                total_posts=parseInt(aData.posC)+parseInt(aData.negC)
                var html_theme= '<strong class="media-box-heading text-primary"><a style="cursor:pointer" onclick="themeview('+aData.theme+')">'+aData.theme+'</a></strong>'
                var html_fd=    '<a title="Translate" target="_blank" href="https://translate.google.co.in/#auto/en/'+aData.theme+'"><em class="icon-note"></em></a>'
                var html_total_posts=   total_posts
                var html_positive_posts='<a href="#"onclick="themeview("")";>'+aData.posC+'</a>'
                var html_negative_posts='<a href="#"onclick="themeview("")";>'+aData.negC+'</a>'
                var html_neutral_posts='<a href="#"onclick="themeview("")";>'+aData.neuC+'</a>'+'<div class="pull-right"><button class=" mb-sm btn btn-warning" type="button" onclick="themeview(" ");">View Posts</button></div>'
                /*
                var html_keyword = '<a target="_blank" href="/pages/app/query.html?word='
                        + aData.keyword
                        + '"title="Click to do a keyword search">'
                        + aData.keyword
                        + '</a>'
                var html_delete = '<a class="fa fa-remove" onclick="delChannel(\''
                        + aData.keyword
                        + '\')" title="Delete"></a>'
                 */

                $('td:eq(0)', nRow).html(
                        html_theme);
                $('td:eq(1)', nRow).html(
                        html_translate);
                $('td:eq(2)', nRow).html(
                        html_total_posts);

                $('td:eq(3)', nRow).html(
                        html_positive_posts);

This question has an accepted answers - jump to answer

Answers

  • Niranjan12345Niranjan12345 Posts: 3Questions: 1Answers: 1

    I mean only first request is working for the page, subsequent requests are not sent to the back end url

  • Niranjan12345Niranjan12345 Posts: 3Questions: 1Answers: 1
    Answer ✓

    fixed it had to use destroy function

This discussion has been closed.