Mistake

I just had the first 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 can I handle this? Firefox closes and IE displays an error

+3
source share
2 answers

You have two functions with the same name: getMapDetails

+1
source

Step 1: Upgrade to the Latest Firefox

Step 2: Install Firebug

Step 3. After these two steps, Firefox will no longer crash when you try to run this script. If so, try wrapping it all in try / catch and catch an exception that throws. If this is not a failure, the exception should simply be logged on your Firebug console as usual (if you enabled it).

4. , , , , , .

, ( ).

0

Source: https://habr.com/ru/post/1722641/


All Articles