开发者

"script stack space quota is exhausted" error with jquery, xml parsing

Using jquery, my code parse kml file, and get information from the xml file. the code is following:

    $.ajax({
        type:'POST',
        url: '/getKmlFile',
        data: {fname: "route.kml"},
        cache: false,
        dataType: 'xml',
        complete: function(data, status){
            console.debug("here");
            var startTime = $(data.responseText).find('TimeSpan > begin').text();
            .....
            .....
            $(data.responseText).find('LineString').each(function (index) {
                ....
            }
            ....
    });

the problem is, firefox make an error log, "script stack space quota is exhausted". and the execution is exited in this line:

var startTime = $(data.responseText).find('TimeSpan > begin').text();

I just use jquery default selector, and find xml elements. That's all what I did.

kml file size is not so big, it's just 1.6Mbyte.

is there any way to avoid this problem? Usin开发者_StackOverflow中文版g another xml parser? help me please~~~ : )


I resloved the problem.

the solution was very simple.

complete: function(data, status){    => success: function(data, status){ 

in complete function data.responseText is string not xml object, but, in success function data is xml object.

following code should be like this,

$(data).find("...") ...                not, $(data.responseText).find("...") ...

so, less memory and very effecient traversing~

interesting~ ^^;

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜