长字符串在Firefox中自动被截断,而在谷歌浏览器中其工作完美

Long string gets truncated automatically in Firefox while in Google chrome its working perfectly

本文关键字:谷歌浏览器 工作 完美 Firefox 字符串      更新时间:2023-09-26

下面是我的代码块,我通过web服务检索一个json字符串。
是的,它在XML标签中。所以我读取这个标签并使用jQuery解析器解析它jQuery. parsejson (xml.getElementsByTagName("string")[0].firstChild.nodeValue);

 $.ajax({ type: "POST",
        url: "http://localhost:14734/services/Project.asmx/GetProjectHistory",
        dataType: "xml",
        processData: true,
        error: function(XMLHttpRequest, textStatus, errorThrown) { ajaxError(XMLHttpRequest, textStatus, errorThrown); },
        success: function(xml) {
            var t = xml.getElementsByTagName("string")[0].firstChild.nodeValue;
            alert(t);
            var data = jQuery.parseJSON(xml.getElementsByTagName("string")[0].firstChild.nodeValue);
            GetProjectsActivity(data);
            GetUpcommingTask(data);
            // alert(data);
        }
    });

我得到完整的字符串响应,正如我所期望的。但在FireFox中,我看到这个字符串被截断了。
jQuery.parseJSON (xml.getElementsByTagName("字符串")[0] .firstChild.nodeValue);

截断的字符串如下…

{"列表":{"表":[{"HDate":"9月15日","ActionDateTime":"/日期(1316049833340 + 0530)/"、"HTime":"06:53:53"、"用户名":dev1intelligent, Project_Name: yrr, EntityType: Project,ActionType: "is Deleted", ID: 445, hID: 825}, {"HDate": "15 ., "ActionDateTime": "/Date(1316049831280+0530)/", "HTime":"06:53:51", "UserName": " dev1intelligent ", "Project_Name": "yrr",EntityType: Project, ActionType: is Deleted, ID: 445,"hID": 824}, {"HDate": "15 Sep ", "ActionDateTime":"/日期(1316047802467 + 0530)/"、"HTime":"06:20:02"、"用户名":dev1intelligent, Project_Name: yrr, EntityType: Project,"ActionType": "is Inserted", "ID": 445, "hID": 823}, {"HDate": "14 ., "ActionDateTime": "/Date(1315984624977+0530)/", "HTime":"12:47:04", "UserName": " dev1intelligent ", "Project_Name":"1315049911_administrator.png", "EntityType": "File ", "ActionType":"插入"、"ID":51岁的"藏":819},{"HDate":"9月14日","ActionDateTime": "/Date(1315984411087+0530)/", "HTime": "12:43:31",UserName: dev1intelligent, Project_Name:"1315049980_coral .png", "EntityType": "File ", "ActionType": "is "插入"、"ID":50岁"藏":818},{"HDate":"9月14日","ActionDateTime": "/Date(1315983619353+0530)/", "HTime": "12:30:19",UserName: dev1intelligent, Project_Name: stage3, EntityType:"Stage ", "ActionType": "is Deleted", "ID": 1266, "hID": 817}, {"HDate": "14 Sep ", "ActionDateTime": "/Date(1315983554447+0530)/",HTime": "12:29:14", "UserName": " dev1intelligent ", "Project_Name":"fgdfgdfgdfg", "EntityType": "Step ", "ActionType": "is Inserted",ID: 1284, hID: 816}, {HDate: 14 Sep ", "ActionDateTime":"/日期(1315982622400 + 0530)/"、"HTime":"12:13:42"、"用户名":" dev1intelligent ", "Project_Name": "sdfsdssdfs", "EntityType": "Step ","ActionType": "is Inserted", "ID": 1281, "hID": 799}, {"HDate":, "ActionDateTime": "/Date(1315982619307+0530)/", "HTime":"12:13:39", "UserName": " dev1intelligent ", "Project_Name": "sdfsdssdfs","EntityType": "Step ", "ActionType": "is Inserted", "ID": 1280, "hID":, {"HDate": "14 Sep ", "ActionDateTime":"/日期(1315980254543 + 0530)/"、"HTime":"11:34:14"、"用户名":" dev1intelligent ", "Project_Name": "stage1", "EntityType": "Stage ",ActionType: "is Deleted", ID: 1255, hID: 792}, {"HDate": "14 ., "ActionDateTime": "/Date(1315970910450+0530)/", "HTime":"08:58:30", "UserName": " dev1intelligent ", "Project_Name": "stage",EntityType: Stage, ActionType: is Updated, ID: 1251, hID:, {"HDate": "14 Sep ", "ActionDateTime":"/日期(1315970792030 + 0530)/"、"HTime":"08:56:32"、"用户名":" dev1intelligent ", "Project_Name": "step", "EntityType": "step",ActionType: "is Updated", ID: 1252, hID: 740}, {"HDate": "14 ., ActionDateTime:/Date(1315970754793+0530)/, HTime:"08:55:54", "UserName": " dev1intelligent ", "Project_Name": "step","EntityType": "Step ", "ActionType": "is Updated", "ID": 1252, "hID":, {"HDate": "14 Sep ", "ActionDateTime":"/日期(1315970743077 + 0530)/"、"HTime":"08:55:43"、"用户名":" dev1intelligent ", "Project_Name": "step", "EntityType": "step","ActionType": "is Up



是的,它不是一个有效的json字符串,所以当jQuery。函数试图解析它,然后它抛出错误,由于无效的json格式。

在谷歌浏览器一切顺利,没有错误。

你应该试试这个…

https://bugzilla.mozilla.org/show_bug.cgi?id=194231

function nodeValue(xmlTag){
 if(xmlTag.firstChild.textContent && xmlTag.normalize) {
  xmlTag.normalize(xmlTag.firstChild);
  content=xmlTag.firstChild.textContent;
  } else if(xmlTag.firstChild.nodeValue) {
   content=xmlTag.firstChild.nodeValue;
  } else {
   content=null;
  }
 return content;
}

在许多浏览器中,警告对话框会截断字符数。这是设计的,因为一个大的警告窗口将是笨拙的。

最好的解决方案是使用console.log(data),它会将数据打印到Firebug/Developer Tools。