Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 未捕获的SyntaxError:输入意外结束——在带有onclick的PHP内部_Javascript_Php_Html_Onclick - Fatal编程技术网

Javascript 未捕获的SyntaxError:输入意外结束——在带有onclick的PHP内部

Javascript 未捕获的SyntaxError:输入意外结束——在带有onclick的PHP内部,javascript,php,html,onclick,Javascript,Php,Html,Onclick,getReport.php <?php $data = $_POST; //print_r($_POST); if (isset($_POST['idws'])) { $getListData = new getListData(); $List = $getListData->get($_POST['idws']); print_r($List); }

getReport.php

<?php 
    $data = $_POST;
        //print_r($_POST);
    if (isset($_POST['idws']))
    {   
            $getListData = new getListData();
            $List = $getListData->get($_POST['idws']);
            print_r($List);
    }
    else{
        exit;
    }
    class getListData {
        public function get($idws){
            include __DIR__ .'/../../../include/conn.php';
            $q = "SELECT * from customers where idws= '$idws'
            ORDER BY idws DESC";
            $stmt = mysql_query($q);
            $id = array();
            $outp = '';
            while($row = mysql_fetch_array($stmt)){
                if ($outp != "") {$outp .= ",";}
                $outp .= '{"item_d":"'.rawurlencode($row['item_desc']).'",';
                $outp .= '"qty":"'. rawurlencode($row["qty"]). '"}';    
            }
            $result = '{ "status":"ok", "message":"1", "records":['.$outp.']}';
            return $result;
        }
    }

    ?>
为此:

onclick='getReport(".'"'.$data['id'].'"'.")'
但我得到了这个错误:

Uncaught ReferenceError: getReport is not defined
    at HTMLDivElement.onclick
老实说,我仍然不知道如何阅读带有这么多引号的正确标签。请帮我解决这个问题。

您可以这样做:

<?php echo "<div style='cursor:pointer; color:#3386FF' data-toggle='modal' data-target='.detmatstat' onclick='getReport(".$data[id].")'>".$data[id]."</div>";
 ?>
您可以这样做:

<?php echo "<div style='cursor:pointer; color:#3386FF' data-toggle='modal' data-target='.detmatstat' onclick='getReport(".$data[id].")'>".$data[id]."</div>";
 ?>

是否存在
getReport
javascript函数?因为错误是说它没有,至少在打电话的时候没有。。。而
getReport
是否在全局范围内?@zanderwar
getReport
错误,它不存在,因为我切换了单引号和双引号。这是不正确的。当我撤销它时,我得到输入错误的结尾。FWIW,数字不需要用引号封装。
getReport
javascript函数存在吗?因为错误是说它没有,至少在打电话的时候没有。。。而
getReport
是否在全局范围内?@zanderwar
getReport
错误,它不存在,因为我切换了单引号和双引号。这是不正确的。当我撤销它时,我得到输入错误的结尾。FWIW,数字不需要用引号封装
<?php echo "<div style='cursor:pointer; color:#3386FF' data-toggle='modal' data-target='.detmatstat' onclick='getReport(".$data[id].")'>".$data[id]."</div>";
 ?>