C
C
CODALSD2018-06-01 15:54:38
JavaScript
CODALSD, 2018-06-01 15:54:38

Which side is wrong? PHP or JS?

https://www.vgl.su/tester/
There is such a page with a map. You can select country and city. But when you try to add additional cities and offices for Kazakhstan or Ukraine, the map stops working. How can you find out where the error is?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Proskurin, 2018-06-01
@CODALSD

Look for the eternal loop in the JS code, the browser tab freezes tightly, loading the CPU cores.
UPD: I looked in the chrome debugger, it says that it hangs in this area.

$( "#ShipStates option:selected" ).each(function() {

          	var data_lat = $(this).attr("data-lat");
          	var data_long = $(this).attr("data-long");

            for(var countrycode in dealersArray)
            {	country = dealersArray[countrycode];
              for(var citycode in country.cities)
              {	city = country.cities[citycode]
                for (var i = 0; i < city.offices.length; i++)
                {	office = city.offices[i]
                    var latLng = new google.maps.LatLng(data_lat, data_long);

                    mapBuy.setZoom(11);
                    mapBuy.panTo(latLng);
                    return;
                }
              }
            }
    
})

I believe this is because for Kazakhstan, in the cities in the select option, the data-coord attributes are undefined. Try to fix it, it will probably help.

E
Egor Zhivagin, 2018-06-01
@Krasnodar_etc

Where are they added? How are they added? How are they output?
What does the console write on error? What do the backend logs say?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question