Javascript Chrome,Safari-未捕获类型错误:无法读取属性';状态';空的
我每半分钟发送一次请求,然后在页面上显示更新后的帖子,以此更新我页面上的一些帖子 它在FireFox中工作正常,但在Chrome和Safari中工作正常,显示错误“无法读取null的属性'status'。下面是我发送请求并在成功时显示结果的JavaScript代码Javascript Chrome,Safari-未捕获类型错误:无法读取属性';状态';空的,javascript,ajax,zend-framework,Javascript,Ajax,Zend Framework,我每半分钟发送一次请求,然后在页面上显示更新后的帖子,以此更新我页面上的一些帖子 它在FireFox中工作正常,但在Chrome和Safari中工作正常,显示错误“无法读取null的属性'status'。下面是我发送请求并在成功时显示结果的JavaScript代码 var updatePost = function() { var lastid = document.getElementById('lastTopic').value; en4.core.request.sen
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);
}
}
}));
};
var updatePost=function(){
var lastid=document.getElementById('lastTopic')。值;
en4.core.request.send(new request.JSON({
url:en4.core.baseUrl+“组/主题/主题更新”,
数据:{
格式:“json”,
拉斯蒂德:拉斯蒂德,
主题id:“”,
组id:“”,
},
onRequest:function()
{
},
onSuccess:函数(responseObject){
if(响应对象状态){
//删除旧的最后一个主题id
$('lastTopic').remove();
//在列表顶部添加通知
$('topicUpdateNotify')。innerHTML=“”;
//将li附加到包含内容的列表中
var ul=document.getElementById(“组讨论线程”);
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)