Php SyntaxError{stack:(…),消息:“意外令牌”lt;}

Php SyntaxError{stack:(…),消息:“意外令牌”lt;},php,json,Php,Json,我正在使用jqueryajax调用 var data="name"+get_name; $.ajax({ type:"GET", url:"php/getAllInfo.php", data:data, dataType:"json", success: function(data){ var allDetails=data;

我正在使用jqueryajax调用

var data="name"+get_name;
        $.ajax({
            type:"GET",
            url:"php/getAllInfo.php",
            data:data,
            dataType:"json",
            success: function(data){
                var allDetails=data;
                console.log(allDetails);
            },
            error:function(jqXHR, textStatus, errorThrown){
             console.log(errorThrown);
            },
             complete: function(){

            }
        });
php

mysqli语句是正确的。但它给出了语法错误,什么是编码错误。此处,cpuUtilization值为NULL

我想要像{deviceId:'idvalue',cpuUtilization:'value'}

Edit var data=“name”+get\u name
to
var data=“name=“+get\u name


检查您的响应,如果响应不是json格式或json无效,则发生错误

什么是
var\u dump($Response)
输出?请编辑您的问题以包含这些信息。我想您想要的是修复ajax数据,从“数据:数据”到“数据:{name:get_name}”,有什么区别?
$name = trim($_GET['name']);

$mysql_resultset = mysqli_query($con, "SELECT dod.deviceId, drs.cpuUtilization FROM device_owner_details dod, device_realtime_stats drs WHERE  dod.name = '$name' AND drs.deviceId= dod.deviceId ");

$rows_data = mysqli_fetch_assoc($mysql_resultset);

$all_details = array('deviceId'=> $rows_data['deviceId'], 'cpuUtilization' => $rows_data['cpuUtilization']);

$response = json_encode($all_details);
echo $response;