Chrome,Safari - 未捕获的类型错误:无法读取 null 的属性“状态”
Chrome,Safari - Uncaught TypeError: Cannot read property 'status' of null
我通过每半分钟发送一次请求然后在页面上显示更新的帖子来更新页面上的一些帖子。
它在FireFox中工作正常,但在Chrome和Safari中,显示错误"无法读取null的属性'状态'"。以下是我的JavaScript代码,用于发送请求并在成功时显示结果。
var updatePost = function() {
var lastid = document.getElementById('lastTopic').value;
en4.core.request.send(new Request.JSON({
url : en4.core.baseUrl + 'group/topic/topic-update',
data : {
format : 'json',
lastid : lastid,
topic_id : '<?php echo $this->topic->getIdentity(); ?>',
group_id : '<?php echo $this->group->getIdentity(); ?>',
},
onRequest:function()
{
},
onSuccess : function(responseObject) {
if(responseObject.status) {
// Remove old last topic id
$('lastTopic').remove();
//Add notification at top of list
$('topicUpdateNotify').innerHTML = "<a href='javascript:void(0);' onclick='scrollToPost("+responseObject.newLastId+");'>New Post update is available - click this to show it. </a>";
// Append li to list with content
var ul = document.getElementById("group_discussions_thread");
var newLI = document.createElement("LI");
newLI.innerHTML = responseObject.body;
ul.appendChild(newLI);
}
}
}));
};
请求成功后,我已使用 if(responseObject.status) {}
检查了状态。它在FF中正常工作,但在Chrome和Safari中未显示结果。
我正在使用 zend 框架。
请提出任何解决方案。
尝试使用
if(typeof responseObject.status != 'undefined')
或
if(responseObject.hasOwnProperty('status'))
或
if('status' in responseObject)
学分来自:JavaScript isset() 等效
相关文章:
- 字符串在将其传递给另一个活动Android JavaScript时读取Null
- 我该如何解决这个问题?“未捕获的类型错误:无法读取 null 的属性'appendChild'”
- Catch无法读取null的属性
- select2:无法读取null的属性查询
- 获得'无法读取null的属性样式'
- 未捕获的类型错误:无法读取 null 的属性“removeChild”(使用 Instagram 的 JSONP 响应)
- 未捕获的类型错误:无法读取 null 的属性“toLowerCase”
- JAVASCRIPT - 未捕获的类型错误:无法读取 null 的属性“值”
- Google Map API BackBoneJS 无法读取 null 的属性 'offsetWidth'
- 未捕获的类型错误:无法读取 null 的属性“选项” - 某些代码有效
- WebGL-无法读取null的属性createShader
- Quicksort.js未捕获的typeError无法读取null的属性
- Google MAP API 未捕获类型错误:无法读取 null 的属性“offsetWidth”
- Highcharts'无法读取null'的属性tooltipOptions;
- ReactNative-ListView中的Tapping行出现错误:无法读取null的属性“_pressRow”
- 无法在具有linkedState的reactJs中读取null值
- 无法读取Null的属性样式
- ng-cordova sqlite 插件:类型错误:无法读取 null 的属性“事务”
- 处理“无法读取 null 的属性”错误
- 类型错误: 无法读取 null 的属性“insertBefore”