1

I am trying to send data via AJAX and process them in another page with query and get the response to be processed in datatables.

here is my code,

OutstandingProcess.php

    var subjob = '<?php echo $subjob; ?>';
        $.ajax({
            dataType: 'JSON',
            type:"POST",
            data:{subjob:subjob},
            url:'divpages/OutstandingProcessFabJSON.php',
            success : function (data) { 
                alert(data.msg);
            }
        });

and on the OutstandingProcessFabJSON.php,

$subjob = $_POST['subjob'];

$fabDtlSql = oci_parse($conn, "SELECT VFI.* FROM VW_FAB_INFO VFI WHERE VFI.PROJECT_NAME = '$subjob'");
oci_execute($fabDtlSql);

$rows = array();
while ($r = oci_fetch_assoc($fabDtlSql)) {
    $rows[] = $r;
}
$fabDtl = json_encode($rows, JSON_PRETTY_PRINT);
$fabDtlCount = count($rows);

I need to get the response for $fabDtlCount and $fabDtl $fabDtl needed for DataTables ajax call.

So far I get no response. Please help me

0

1 Answer 1

2

You have to print or echo your data in OutstandingProcessFabJSON.php file.

$subjob = $_POST['subjob'];

$fabDtlSql = oci_parse($conn, "SELECT VFI.* FROM VW_FAB_INFO VFI WHERE VFI.PROJECT_NAME = '$subjob'");
oci_execute($fabDtlSql);

$rows = array();
while ($r = oci_fetch_assoc($fabDtlSql)) {
    $rows[] = $r;
}
$fabDtl = json_encode($rows, JSON_PRETTY_PRINT);
$fabDtlCount = count($rows);
echo $fabDtlCount;// this you can capture in ajax success().

Now you want more that one value from ajax filr. So add all required values in to a array, then json_encode() that array

$fabDtl = $rows;// remove encode here
$fabDtlCount = count($rows);
$arr["fabDtl"] = $fabDtl;
$arr["fabDtlCount"] = $fabDtlCount;
echo json_encode($arr);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.