开发者

stack overflow error

i just got my first ever stack overflow when I ran this script:

var hlat = 0.00;
var hlong = 0.00;
var mapdiv = document.getElementById('map');
var map_url = base_url + 'ajax/getPropMap';
var id_url = base_url + 'hotels/gethotel_id';
var id=0;
var map = null;
// apply gmaps to product map div

$(function(){
    $.get(id_url, {id: segment}, getMapDetails);
});

function getMapDetails(data){
    $.getJSON(map_url, {id:data}, addToProdMap);
}

function getMapDetails(data){
    addProdMap(data);
}

function addProdMap(data){
    hlat = data.latitude;
    hlong = data.longitude;

    map = new google.maps.Map(mapdiv, {
            center : new google.maps.LatLng(hlat, hlong),
            zoom : 13,
            mapTypeId : 'hybrid'
    });

    var coords = new google.maps.LatLng(hlat, hlong);
    var marker = new google.maps.Marker({
        clickable : true,
        map: map,
        icon : 'http://labs.google.com/ridefinder/images/mm_20_red.png',
        position : coords
    })
}

How do I deal with this? Fir开发者_C百科efox closes and IE displays the stack overflow error


You have two functions of the same name: getMapDetails


Step 1: Upgrade to the latest Firefox

Step 2: Install Firebug

Step 3: After those two steps Firefox should no longer crash when you try and run that script. If it does, try wrapping the whole thing in a try/catch and log the exception which gets caught. If it doesn't crash, the exception should just be logged to your Firebug console as normal (assuming you have it turned on).

Step 4: Now that you've actually got an exception you can look at, just follow the stacktrace to see what line in particular is causing the problem.

Hope that works (but if not comment back).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜