开发者

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

Below is my block of code where I am retrieving one json string through web service.

Yes it is in XML tag. So I read this tag and parse it using jQuery parser 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);
        }
    });

I am getting full string in response as I expected. But in FireFox I see that string is truncated.

jQuery.parseJSON(xml.getElementsByTagName("string") [0].firstChild.nodeValue);

Truncated string is as below ...

{"List":{ "Table": [ { "HDate": "15 Sep ", "ActionDateTime": "/Date(1316049833340+0530)/", "HTime": "06:53:53", "UserName": "Dev1Intellial", "Project_Name": "yrr", "EntityType": "Project ", "ActionType": "is Deleted", "ID": 445, "hID": 825 }, { "HDate": "15 Sep ", "ActionDateTime": "/Date(1316049831280+0530)/", "HTime": "06:53:51", "UserName": "Dev1Intellial", "Project_Name": "yrr", "EntityType": "Project ", "ActionType": "is Deleted", "ID": 445, "hID": 824 }, { "HDate": "15 Sep ", "ActionDateTime": "/Date(1316047802467+0530)/", "HTime": "06:20:02", "UserName": "Dev1Intellial", "Project_Name": "yrr", "EntityType": "Project ", "ActionType": "is Inserted", "ID": 445, "hID": 823 }, { "HDate": "14 Sep ", "ActionDateTime": "/Date(1315984624977+0530)/", "HTime": "12:47:04", "UserName": "Dev1Intellial", "Project_Name": "1315049911_administrator.png", "EntityType": "File ", "ActionType": "is Inserted", "ID": 51, "hID": 819 }, { "HDate": "14 Sep ", "ActionDateTime": "/Date(1315984411087+0530)/", "HTime": "12:43:31", "UserName": "Dev1Intellial", "Project_Name": "1315049980_coraline.png", "EntityType": "File ", "ActionType": "is Inserted", "ID": 50, "hID": 818 }, { "HDate": "14 Sep ", "ActionDateTime": "/Date(1315983619353+0530)/", "HTime": "12:30:19", "UserName": "Dev1Intellial", "Project_Name": "stage3", "EntityType": "Stage ", "ActionType": "is Deleted", "ID": 1266, "hID": 817 }, { "HDate": "14 Sep ", "ActionDateTime": "/Date(1315983554447+0530)/", "HTime": "12:29:14", "UserName": "Dev1Intellial", "Project_Name": "fgdfgdfgdfg", "EntityType": "Step ", "ActionT开发者_如何学Cype": "is Inserted", "ID": 1284, "hID": 816 }, { "HDate": "14 Sep ", "ActionDateTime": "/Date(1315982622400+0530)/", "HTime": "12:13:42", "UserName": "Dev1Intellial", "Project_Name": "sdfsdssdfs", "EntityType": "Step ", "ActionType": "is Inserted", "ID": 1281, "hID": 799 }, { "HDate": "14 Sep ", "ActionDateTime": "/Date(1315982619307+0530)/", "HTime": "12:13:39", "UserName": "Dev1Intellial", "Project_Name": "sdfsdssdfs", "EntityType": "Step ", "ActionType": "is Inserted", "ID": 1280, "hID": 798 }, { "HDate": "14 Sep ", "ActionDateTime": "/Date(1315980254543+0530)/", "HTime": "11:34:14", "UserName": "Dev1Intellial", "Project_Name": "stage1", "EntityType": "Stage ", "ActionType": "is Deleted", "ID": 1255, "hID": 792 }, { "HDate": "14 Sep ", "ActionDateTime": "/Date(1315970910450+0530)/", "HTime": "08:58:30", "UserName": "Dev1Intellial", "Project_Name": "stage", "EntityType": "Stage ", "ActionType": "is Updated", "ID": 1251, "hID": 741 }, { "HDate": "14 Sep ", "ActionDateTime": "/Date(1315970792030+0530)/", "HTime": "08:56:32", "UserName": "Dev1Intellial", "Project_Name": "step", "EntityType": "Step ", "ActionType": "is Updated", "ID": 1252, "hID": 740 }, { "HDate": "14 Sep ", "ActionDateTime": "/Date(1315970754793+0530)/", "HTime": "08:55:54", "UserName": "Dev1Intellial", "Project_Name": "step", "EntityType": "Step ", "ActionType": "is Updated", "ID": 1252, "hID": 739 }, { "HDate": "14 Sep ", "ActionDateTime": "/Date(1315970743077+0530)/", "HTime": "08:55:43", "UserName": "Dev1Intellial", "Project_Name": "step", "EntityType": "Step ", "ActionType": "is Up

Yes, it is not a valid json string so when jQuery.parseJson function trying to parse it then it throws errors due to the invalid json format.

In Google chrome all goes well without error. Problem is only with FireFox.


You should try this..

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;
}


The alert dialog truncates the number of characters in many browsers. This is by design, since a large alert window would be unwieldy.

The best solution is to use console.log(data), which will print the data to Firebug/Developer Tools.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜