响应Ajax调用,我收到一个对象列表。当我尝试将其传递给另一个函数以在表中显示该列表时,它显示“超出最大调用堆栈大小”错误。我只调用该函数一次,即不在循环中,但它会从函数反复显示第一个警告'welcome'。它没有击中函数中的任何剩余警报。我该如何解决?
** ajax代码:**
$.ajax({
url: "Read_Quran?ayah="+ayah,
type: 'GET',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
async: false,
data: '',
success: function (result)
{
alert("back to succes.!");
var mera_obj = result.key;
show_table(mera_obj,0,10);
return false;
},
error: function (xhr, ajaxOptions, thrownError)
{
alert("Error : " + xhr.responseText);
},
});
功能:
function show_table(mera_obj,start,end)
{
alert("welcome " +start +" " +end);
var nrCols=3;
var maxRows=10;
var nrRows=maxRows+1;
var root=document.getElementById('mydiv');
var tab=document.createElement('table');
tab.style.width='800';
tab.style.backgroundColor = 'white' ;
tab.setAttribute('Border','1');
tab.className="mytable";
var tbo=document.createElement('tbody');
var tr1= document.createElement('tr');
var th1= document.createElement('th');
th1.appendChild(document.createTextNode('Ayat_#'));
th1.style.width='60';
var th2= document.createElement('th');
th2.appendChild(document.createTextNode('Verse'));
var th3= document.createElement('th');
th3.appendChild(document.createTextNode('Translation'));
alert("Second setp");
tr1.appendChild(th1);
tr1.appendChild(th2);
tr1.appendChild(th3);
tbo.appendChild(tr1);
alert("before showing");
for (index = 0; index < 1/*mera_obj.length*/; ++index)
{
//jquery code for table
var row, cell;
row=document.createElement('tr');
cell1=document.createElement('td');
cell1.appendChild(document.createTextNode(mera_obj[index].ayah)) //ayah no
cell2=document.createElement('td');
cell2.appendChild(document.createTextNode(mera_obj[index].verse)) // contents
cell2.style.width="350";
cell3=document.createElement('td');
cell3.appendChild(document.createTextNode('not_available')) // translation
row.appendChild(cell1);
row.appendChild(cell2);
row.appendChild(cell3);
tbo.appendChild(row);
// alert(mera_obj[index].surah_name+" >"+mera_obj[index].verse + mera_obj[index].surah);
}
tab.appendChild(tbo);
var BB= document.createElement('input');
BB.setAttribute('type','button');
BB.setAttribute('value','<<Back');
BB.style.position="relative";
BB.style.left="2";
var FB= document.createElement('input');
FB.setAttribute('type','button');
FB.setAttribute('value','Next>>');
FB.style.position="relative";
FB.style.left="20";
var RT= document.createElement('input');
RT.setAttribute('type','text');
RT.setAttribute('value','10');
RT.style.position="relative";
RT.style.left="30";
RT.style.width="45";
RT.setAttribute('placeholder','Range');
root.appendChild(tab);
root.appendChild(BB);
root.appendChild(FB);
root.appendChild(RT);
return false;
}