JQuery Data tables Invalid JSON Response

JQuery Data tables Invalid JSON Response

sangireddisangireddi Posts: 2Questions: 0Answers: 0

<link type="text/css" rel="stylesheet" href="/springmvclogin/resources/static/css/jquery.dataTables.css">

<script type="text/javascript" src="<spring:url value="/resources/static/js/jquery-1.10.2.js" />"></script>
<script type="text/javascript" src="<spring:url value="/resources/static/js/jquery.dataTables.js" />"></script>
//Plug-in to fetch page data jQuery.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) { alert("Plugin to fetch page data .....first javascript function **"); return { "iStart": oSettings._iDisplayStart, "iEnd": oSettings.fnDisplayEnd(), "iLength": oSettings._iDisplayLength, "iTotal": oSettings.fnRecordsTotal(), "iFilteredTotal": oSettings.fnRecordsDisplay(), "iPage": oSettings._iDisplayLength === -1 ? 0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ), "iTotalPages": oSettings._iDisplayLength === -1 ? 0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength ) }; }; $(document).ready(function() { $("#example").dataTable( { "bProcessing": true, "bServerSide": true, "sort": "position", //bStateSave variable you can use to save state on client cookies: set value "true" "bStateSave": false, //Default: Page display length "iDisplayLength": 10, //We will use below variable to track page number on server side(For more information visit: http://legacy.datatables.net/usage/options#iDisplayStart) "iDisplayStart": 0, "fnDrawCallback": function () { //Get page numer on client. Please note: number start from 0 So //for the first page you will see 0 second page 1 third page 2... //Un-comment below alert to see page number alert("Current page number: "+this.fnPagingInfo().iPage); }, "sAjaxSource": "${pageContext.servletContext.contextPath}/form/springPaginationDataTables.web", "aoColumns": [ { "mData": "patientId" }, { "mData": "patientName" }, { "mData": "sex" }, { "mData": "age" }, { "mData": "test" }, { "mData": "Description" }, { "mData": "noOfInstances" }, { "mData": "dateOfUpload" }, { "mData": "dateOfReport" }, { "mData": "center" }, { "mData": "noOfReports" }, ] } ); } );

Below is my web.xml url pattern

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/form/*</url-pattern>
</servlet-mapping>

It Seems like data in Juery.js is still taking jsp page from where i gave request instead of data from datatables.js

Can any please suggest me where i am doing wrong

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Per the forum rules, please link to a test case showing the issue. If you could also use Markdown to highlight the code and make it readable that would be helpful.

    Allan

This discussion has been closed.