ajax response to datatables sqlsrv with ajax & php pagination
ajax response to datatables sqlsrv with ajax & php pagination
nnkrishnana
Posts: 9Questions: 1Answers: 0
I am selecting a value(state) from dropdown Page (send.php), after i am processing filter state data in (response.php), this data need to display page (send.php), i am try to use but getting raw json data, it's not showing in datatbles.How to show data from json response into datatable.
This discussion has been closed.
Answers
Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.
Information on how to create a test page], if you can't provide a link to your own page can be found here.
Thanks,
Allan
this code is from ( send.php )
<
script type="text/javascript">
function showUser()
{
var state = document.getElementById('state').value;
if (state=="")
{
document.getElementById("example1").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
//function test();
var a = xmlhttp.responseText;
alert(a);
}
document.getElementById("loading").innerHTML = '<img src="35.gif" />';
xmlhttp.open("GET","getuser.php?state="+state+,true);
xmlhttp.send();
}
My json code from response.php
{"draw":1,"iTotalRecords":1,"iTotalDisplayRecords":1,"aaData":[{"ID":1731166,"INDUSTRY":"3545 Cutting Tools Machine Tool Accessory & Precision Measuring Device Mfg","COMPANYNAME":"Curran Manufacturing Corp","TITLE":"President","NAICS":null,"SICCODES":"3545"}]}
Running environment is Windows server, XAMPP, PHP, MSSQL (sql server 2012)
https://jsfiddle.net/je76wfkd/
Thanks for the link to the JSFiddle - however it gives a number of syntax errors. I'm presuming you don't have those syntax errors locally. Can you link to a running test case so the issue can be debugged please.
Allan
http://businesssetup.lk/demo/data.php refer this link
I can get results from the get.php but problem is showing raw json.i am get ajax response text, so how to convert ajax json response to datatables.
Above mentioned link is simplified for php and mysql ( but my actual work is in Intranet - php,mssql-sqlsrv windows OS)
Use
$.parseJSON
if you want to convert a JSON string to actual JSON. Moreover, I would suggest you use$.ajax
or$.getJSON
to get the JSON data rather than writing your own Ajax handler.Once you have the data, use
rows.add()
to add the data. Also, remove the server-side processing option unless you are actually going to have DataTables make the Ajax requests for you.Allan
Thank you very much for supporting. Finally it's working fine