I am stuck inside a problem I cannot handle easily.
I have create some fields (input and select) without using the <form> tag.
When the user click on the "Research" button starts the following script:
- get all the value from the fields,
send all the fields to a Php page, using the DATATABLES plugin. Here is the code:
function assetSearch() {
var validation = checkForSelectedFields();
if (validation == "KO") return; var arrForm = []; arrForm.push(document.getElementById("name").value); arrForm.push(document.getElementById("idConfig").value); arrForm.push(document.getElementById("serialNumber").value); arrForm.push(document.getElementById("tipo").value); arrForm.push(document.getElementById("ambiente").value); arrForm.push(document.getElementById("modello").value); arrForm.push(document.getElementById("locazione").value); arrForm.push(document.getElementById("vendor").value); arrForm.push(document.getElementById("gruppo").value); arrForm.push(document.getElementById("stato").value); arrForm.push(document.getElementById("classe").value); arrForm.push(document.getElementById("securityLevel").value); arrForm.push(document.getElementById("aggregatore").value); console.log(JSON.stringify(arrForm)); var outcomeResearchTable = document.getElementById("OUTCOME_RESEARCH_TABLE"); outcomeResearchTable.style.display = "flex"; $('#OUTCOME_RESEARCH_TABLE').DataTable( { // "ajax": { // "url": "asset_GestAsset.php", // "type": "POST", // "data": function(d) { // d.form = $("#researchForm").serializeArray(); // } //}, "paging": true, "processing": true, "ajax": "asset_GestAsset.php", "deferLoading": 57, "deferRender": true, "scrollY": 350, "scrollX": true, "bRetrieve": true, "bDestroy": true, "iDisplayLength": 100, "ordering": false, "info": true, "sDom": 'ltipr', "order": [[1, 'asc']] } );}
non at all the fields are mandatory but at least one text input has to be compiled. The point is that Datatables, using the code shown previously, send me back an error: DataTables warning: table id=OUTCOME_RESEARCH_TABLE - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
Just for test, I decided to try the query and show the values on the Datatable, so I decided to don't care about the Ajax problem but another the problem has come: Php tells me "OUT OF MEMORY". Looking at Google Developer Console I have been informed that under the column: STATUS (inside Network) the php page is in "pending" for about 30seconds and the error is:
Fatal error: Out of memory (allocated 559939584) (tried to allocate 25165832 bytes) in
<?php
ini_set('memory_limit', '-1');
include("function.php");
$conn = connectionDB();
$queryOriginale = " select A.ID_CONFIG IDCONF, A.ID_ASSET IDASSET, A.NOME NOME,B.SERIAL_NUMBER SERIALNUMBER, B.TIPO TIPOLOGIA, C.DESCRIZIONE STATO, E.NOME AGGREGATORE,
F.ID_CED,F.SALA,F.FILA,F.POSIZIONE,D.NOME AMBIENTE , H.NOME MODELLO, G.DESCRIZIONE NOMECED, 'n/a' CONTRATTO, A.VALIDA_DAL VALIDADAL,A.VALIDA_AL VALIDAAL
from
PCMDB_INV.ASSET B, PCMDB_INV.CONFIG A, PCMDB_INV.STATO C, PCMDB_INV.AMBIENTE D,
PCMDB_INV.AGGREGATOR E, PCMDB_INV.LOCAZIONE F, PCMDB_INV.CED G, PCMDB_INV.MODELLO H,
PCMDB_INV.SOFTWARE L, PCMDB_INV.SW_CONFIG O, PCMDB_INV.GRUPPO M, PCMDB_INV.TECH_APPLICATION N,
PCMDB_INV.SECURITY_LEVEL P, PCMDB_INV.SEC_LEVEL_CONFIG Q";
$SSS = oci_parse($conn, $queryOriginale);
oci_execute($SSS);
$NUM = oci_fetch_all($SSS, $res);
$stid = oci_parse($conn, $queryOriginale);
oci_execute($stid);
$i = 0;
echo "{ \"aaData\": [\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
$i++;
$a = trim($row["IDCONF"]);
$b = trim($row["NOME"]);
$c = trim($row["TIPOLOGIA"]);
$d = trim($row["STATO"]);
$e = trim($row["AMBIENTE"]);
$f = trim($row["AGGREGATORE"]);
$f2 = trim($row["NOMECED"]);
$g = trim($row["MODELLO"]);
$h = trim($row["CONTRATTO"]);
$l = trim($row["VALIDADAL"]);
$m = trim($row["VALIDAAL"]);
if ($i < $NUM){
echo "[ \"".$a."\", \"".$b."\", \"".$c."\", \"".$d."\", \"".$e."\", \"".$f."\", \"".$f2."\", \"".$g."\", \"".$h."\", \"".$l."\", \"".$m."\" ], \n";
}else {
echo "[ \"".$a."\", \"".$b."\", \"".$c."\", \"".$d."\", \"".$e."\", \"".$f."\", \"".$f2."\", \"".$g."\", \"".$h."\", \"".$l."\", \"".$m."\" ]\n";
}
}
echo "] }";
?>
Someone could help me to solve both of the problems? Many thanks in advance