当然我做错了什么,但我无法实现什么? 我的问题是我正在做一个AJAX请求,我得到了响应,但是当我要把它放在一个JavaScript对象中它失败时,如果它的大小有点大。无论我是尝试JSON还是XML。这是我的代码,我非常感谢任何帮助:
function DataFlow (Target, Txt, Tid, Rid){
var httpObj, obj, row, htm, col, par;
this.tid = Tid;
this.rid = Rid;
if (window.XMLHttpRequest)
httpObj = new XMLHttpRequest();
else if (window.ActiveXObject)
httpObj = new ActiveXObject("Microsoft.XMLHTTP");
else
window.alert ("Navegador nao suporta AJAX");
if (httpObj) {
httpObj.onreadystatechange = function (){
var txt, nrow;
if (this.readyState == 4){
if (this.status != 200)
window.alert ("Pagina nao encontrada: " + Target);
else {
txt = httpObj.responseText;
if (txt == null){
window.alert ("Sem Resposta");
return;
}
window.alert ("Size: " + txt.length + " bytes");
//No Problems Here
obj = eval ('(' + txt + ')');
//Sintaxe Error for Eval or XML for sizes over 300Kb
if (obj == null)
window.alert ("JSON!");
}
};
httpObj.open("POST", Target, true);
httpObj.send(Txt);
}
}