Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82110

Problem Refreshing Data in Server-Side Mode

$
0
0
Hello,

I created an Java/JEE application using Spring mvc.
My goal is to creat a pop-up containing the datatable wich will work in server mode.
Each tap in the filter text box, will call a service that will return a jason response
I used Jquery UI Dialog to contain the datable, it shows fine.

The problem is that when i tape a caractere, the table is leacking on process mode, and it is no refreching.
I tested my Jason response, It's Ok.
And I put some log to see if my service is called every time the user change the filter text box, it's Ok also.

This is the header of my Jsp:

 
<script>
	$(function() {
		var oTable;
		oTable = $("#myTable").dataTable({
			bJQueryUI : true,
			sPaginationType : "full_numbers",
			iDisplayLength : 8,
			"bLengthChange" : false,
			"oLanguage" : {
				"sUrl" : "resources/language/fr.txt"
			},
			"bProcessing" : true,
			"bServerSide" : true,
			cache : false,
			"sAjaxSource" : "/SpringMVC/welcome/recherche",
			"fnServerData" : function(sSource, aoData, fnCallback) {
				$.ajax({
					"dataType" : 'json',
					"type" : "POST",
					"url" : sSource,
					"data" : aoData,
					"success" : fnCallback

				});
			}

		});
/* 	    var newtimer = setInterval( function () {
		 oTable.fnDraw();
		 }, 1000 ); */

		$("#dialog").dialog({
			autoOpen : false,
			modal : true,
			resizable : true,
			width : 705,
			height : 520,
		});

		// Link to open the dialog
		$("#dialog-link").click(function(event) {
			$("#dialog").dialog("open");
			event.preventDefault();
		});

	});
</script>
<style>
body {
	font: 62.5% "Trebuchet MS", sans-serif;
	margin: 50px;
}
</style>
</head>


And this is my function in the Controller side:

 @RequestMapping(value="/recherche", method = {RequestMethod.POST, RequestMethod.GET})
    public @ResponseBody String recherche(@RequestParam String sSearch) {
 
        //Create the response, a well formed JSON including Datatables required vars.
        //e.g.
    	String str = "{  \"sEcho\": 2 ," +
                "   \"iTotalRecords\": 2," +
                "   \"iTotalDisplayRecords\": 2," +
                "   \"aaData\": [" +
                "       [" +
                "           \"Gecko\"," +
                "           \"Firefox 1.0\"," +
                "           \"Win 98+ / OSX.2+\"," +
                "           \"1.7\"," +
                "           \"A\"" +
                "       ]," +
                "       [" +
                "           \"Gecko\"," +
                "           \"Firefox 1.5\"," +
                "           \"Win 98+ / OSX.2+\"," +
                "           \"1.8\"," +
                "           \"A\"" +
                "       ]" +
                "   ]" +
                "}";
    	
    	System.out.println("------------> test : "+sSearch);
    	if(sSearch.equalsIgnoreCase("ok")){
    		System.out.println("------> He's her!!");
            str = "{  \"sEcho\": 2 ," +
                    "   \"iTotalRecords\": 2," +
                    "   \"iTotalDisplayRecords\": 2," +
                    "   \"aaData\": [" +
                    "       [" +
                    "           \"sou\"," +
                    "           \"sou 1.0\"," +
                    "           \"Win 98+ / OSX.2+\"," +
                    "           \"1.7\"," +
                    "           \"A\"" +
                    "       ]," +
                    "       [" +
                    "           \"sou\"," +
                    "           \"sou 1.0\"," +
                    "           \"Win 98+ / OSX.2+\"," +
                    "           \"1.7\"," +
                    "           \"A\"" +
                    "       ]," +
                    "       [" +
                    "           \"sou\"," +
                    "           \"sou 1.0\"," +
                    "           \"Win 98+ / OSX.2+\"," +
                    "           \"1.7\"," +
                    "           \"A\"" +
                    "       ]," +
                    "       [" +
                    "           \"sou\"," +
                    "           \"sou 1.0\"," +
                    "           \"Win 98+ / OSX.2+\"," +
                    "           \"1.7\"," +
                    "           \"A\"" +
                    "       ]," +
                    "       [" +
                    "           \"sou\"," +
                    "           \"sou 1.0\"," +
                    "           \"Win 98+ / OSX.2+\"," +
                    "           \"1.7\"," +
                    "           \"A\"" +
                    "       ]," +
                    "       [" +
                    "           \"sou\"," +
                    "           \"sou 1.0\"," +
                    "           \"Win 98+ / OSX.2+\"," +
                    "           \"1.7\"," +
                    "           \"A\"" +
                    "       ]," +
                    "       [" +
                    "           \"sou\"," +
                    "           \"sou 1.0\"," +
                    "           \"Win 98+ / OSX.2+\"," +
                    "           \"1.7\"," +
                    "           \"A\"" +
                    "       ]," +
                    "       [" +
                    "           \"sou\"," +
                    "           \"sou 1.0\"," +
                    "           \"Win 98+ / OSX.2+\"," +
                    "           \"1.7\"," +
                    "           \"A\"" +
                    "       ]," +
                    "       [" +
                    "           \"sou\"," +
                    "           \"sou 1.0\"," +
                    "           \"Win 98+ / OSX.2+\"," +
                    "           \"1.7\"," +
                    "           \"A\"" +
                    "       ]," +
                    "       [" +
                    "           \"sou\"," +
                    "           \"sou 1.0\"," +
                    "           \"Win 98+ / OSX.2+\"," +
                    "           \"1.7\"," +
                    "           \"A\"" +
                    "       ]," +
                    "       [" +
                    "           \"sou\"," +
                    "           \"sou 1.0\"," +
                    "           \"Win 98+ / OSX.2+\"," +
                    "           \"1.7\"," +
                    "           \"A\"" +
                    "       ]," +
                    "       [" +
                    "           \"zaka\"," +
                    "           \"ziko 1.5\"," +
                    "           \"Win 98+ / OSX.2+\"," +
                    "           \"1.8\"," +
                    "           \"A\"" +
                    "       ]" +
                    "   ]" +
                    "}";
    	}
        return str;
    }

When I tape "Ok" in the filter text box, nothing happen excepte the processing message wich appear.

Thanks for your help.

Maria

Viewing all articles
Browse latest Browse all 82110

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>