Why do I keep getting viewCondition(undefined)?

Why do I keep getting viewCondition(undefined)?

BradleyO07BradleyO07 Posts: 13Questions: 10Answers: 0

I am working on creating a table that will show inspection reports for some equipment. The table displays all my data fine but for my last column I have a view column that when they click on the link, it will show that column on a modal and allow the person looking to print it off. The only problem with this is when I click on the link it doesn't display my modal.

The error I keep getting is "viewCondition(undefined)" and it is displaying within my Developer Tools, on my source tab as a separate file name index.php.

Here is the section of the code where my function viewCondition is typed:

function viewCondition(completed){
    $.ajax({
        url: './ajax/getData.ajax.php',
        type: 'post',
        data: {
            "getCondition": completed,
        },
        dataType: 'json',
        success: function(response) {
            openView(response);
        }
    });
}

Also here is my ajax side of the code that where I am calling it:

function getCondition($completed){
    global $db;
    
    $query = "SELECT * FROM forkliftinspectcomplete WHERE completed=$completed";
    $results = basicQuery($query, $db);
    
    while($result = $results->fetch_assoc()){
        $charFix = str_replace(array("\r\n", "\r", "\\n"), "<br />", $result['driver']);
        $result['inspection'] = stripslashes($result['inspection']);
        $result['driver'] = $charFix;
        return $result;
    }
}

I don't know why I keep getting this error, I am assuming it is because of a typo or maybe I am not calling something correctly.

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    Not sure what this has to do with Datatables. It seems to be a general Javascript issue. Likely its a scoping issue where the function viewCondition is not within the scope of the code calling it. Without seeing your solution its hard to say what the issue is. For help debugging please post a link to your page or a test case replicating the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

Sign In or Register to comment.