我想为我的json回复分配一个变量。我想使用该变量仅回显所选数据
这是我的回复:
IsCovariantIEnumerable(...)
这是我的代码,但收到错误消息:
未定义的索引:C:\ wamp \ www \ echanalling \ test.php中的resultMap
on
{"code":"202","message":"Accepted","data":{"resultMap":{"D1509~H24":{"AppDay":"*","HosTown":"Colombo","SpecName":"Physiotherapist","HosName":"Western Infirmary Hospital (Pvt) Ltd","SpecializationId":"34","HosCode":"H24","AppDate":"Any","DocName":"MR M. HAJITH","DoctorNo":"D1509"},"D0625~H08":{"AppDay":"*","HosTown":"Colombo","SpecName":"Physiotherapist","HosName":"Park Hospital (Pvt) Ltd ","SpecializationId":"34","HosCode":"H08","AppDate":"Any","DocName":"MR JALIYA UDUWELLA","DoctorNo":"D0625"},"D1762~H16":
答案 0 :(得分:0)
您的问题并未显示足够完整且准确的代码,但乍一看我们可以猜到:
$result = json_decode($response,true);
是获取JSON数据内容的地方foreach($result['resultMap']as $data)
是您收到错误的地方从上面的#1开始,你在$result
中得到的内容应该是这样的:
[
"code" => "202",
"message" => "Accepted",
"data" => [
"resultMap" => [
"D1509~H24" => [
"AppDay" => "*",
...
],
"D0625~H08" => [
"AppDay" => "*",
...
],
...
]
]
]
然后从上面的#2开始,您尝试访问$result['resultMap']
时出现错误是完全正常的,$result
不是$result['data']['resultMap']
的第一级密钥。
要访问这部分数据,您应该改为 <input type="button" id="btnNew" class="btnNew" value="New" />
//javascript
$("#btnNew").click(function() {
console.log("show");
$("#diva").style.display = "block";
});
。