Javascript 无法调用方法';toLowerCase';未定义GetJson的类型

Javascript 无法调用方法';toLowerCase';未定义GetJson的类型,javascript,jquery,ajax,json,google-maps-api-3,Javascript,Jquery,Ajax,Json,Google Maps Api 3,在获取Google Maps v3的Jsonresult时,我需要修复代码,但当我在循环中从jquery使用worker加载地图时,此错误显示Uncaught TypeError:无法调用未定义的方法“toLowerCase”我不知道如何修复此问题,并且我看不到存在此问题的某些装置。我希望有人能帮我 这是我的Javascript代码: <script type="text/javascript"> var geocoder; var map; functio

在获取Google Maps v3的Jsonresult时,我需要修复代码,但当我在循环中从jquery使用worker加载地图时,此错误显示
Uncaught TypeError:无法调用未定义的方法“toLowerCase”
我不知道如何修复此问题,并且我看不到存在此问题的某些装置。我希望有人能帮我

这是我的Javascript代码:

<script type="text/javascript">
    var geocoder;
    var map;

    function initialize() {
        var minZoomLevel = 4;
        var zooms = 7;
        geocoder = new google.maps.Geocoder();

        map = new google.maps.Map(document.getElementById('map'), {
            zoom: minZoomLevel,
            center: new google.maps.LatLng(38.50, -90.50),
            mapTypeId: google.maps.MapTypeId.ROADMAP
        });

        // Bounds for North America
        var strictBounds = new google.maps.LatLngBounds(
     new google.maps.LatLng(15.70, -160.50),
     new google.maps.LatLng(68.85, -55.90)
   );

        // Listen for the dragend event
        google.maps.event.addListener(map, 'dragend', function () {
            if (strictBounds.contains(map.getCenter())) return;

            // We're out of bounds - Move the map back within the bounds

            var c = map.getCenter(),
         x = c.lng(),
         y = c.lat(),
         maxX = strictBounds.getNorthEast().lng(),
         maxY = strictBounds.getNorthEast().lat(),
         minX = strictBounds.getSouthWest().lng(),
         minY = strictBounds.getSouthWest().lat();

            if (x < minX) x = minX;
            if (x > maxX) x = maxX;
            if (y < minY) y = minY;
            if (y > maxY) y = maxY;

            map.setCenter(new google.maps.LatLng(y, x));
        });


        // Limit the zoom level
        google.maps.event.addListener(map, 'zoom_changed', function () {
            if (map.getZoom() < minZoomLevel) map.setZoom(minZoomLevel);
        });


    }
    var iconBase = 'https://maps.google.com/mapfiles/kml/shapes/';
    function codeAddress() {
        $.getJSON("/Dashboard/LoadWorkerList", function (address) {
            var infowindow = new google.maps.InfoWindow();
            $.each(address,function (index,currVal) {
               currVal = $(this).val();
                geocoder.geocode({ 'address': currVal }, function (results, status) {
                    if (status == google.maps.GeocoderStatus.OK) {

                        map.setCenter(results[0].geometry.location);
                        var marker = new google.maps.Marker({
                            map: map,
                            icon: iconBase + 'man.png',
                            position: results[0].geometry.location,
                            title: currVal
                        })


                        google.maps.event.addListener(marker, 'click', (function (marker, i) {
                            return function () {
                                infowindow.setContent(currVal);
                                infowindow.open(map, marker);
                            }
                        })(marker, currVal));
                        address.push(marker);
                    }
                    else {
                        alert("Geocode was not successful for the following reason: " + status);
                    }
                });
            });
        });
        return true;
    }

    window.onload = function () {
        initialize();
        codeAddress();
    }
</script>

好的,从stacktrace判断,它是这样说的; -
currVal=$(this.val())中的
$(this.val())返回的值在某个索引处未定义,或
-
$处的
地址
中的一个索引的值。每个(地址、函数(索引、当前值)
都未定义

确保
$中的索引值。每个(地址,函数(索引,currVal){
都没有超出
地址
的长度,并且
地址
中的所有元素都分配了一个值

我猜您试图对数组
address
中的一个地址进行地理编码,它试图将该地址设置为小写字符串,但找不到字符串


如果
address
不是数组,将其设置为数组,它不应该是字符串

您使用哪个浏览器来测试?检查chrome中的元素,在显示此错误的行的左侧应该有一个箭头,单击该箭头以展开stacktrace将stacktrace作为问题的一部分放在此处,也就是说,如果您无法重新读取d一个stacktrace,否则它应该告诉您代码中的确切位置wrong@pythonian29033添加了stacktrace.put此代码:
警报(地址);
直接在以下行之后:
$.getJSON(“/Dashboard/LoadWorkerList”),函数(地址){
并将结果粘贴到问题中…@pythonian29033谢谢谢谢谢谢你能帮我吗?
   public JsonResult LoadWorkerList()
        {
            var workerList = new List<Worker_Address>();

            // check if search string has value
            // retrieve list of workers filtered by search criteria
            var list = (from a in db.Worker_Address
                        where a.LogicalDelete == false
                        select a).ToList();



            List<WorkerAddressInfo> wlist = new List<WorkerAddressInfo>();
            foreach (var row in list)
            {
                WorkerAddressInfo ci = new WorkerAddressInfo
                {
                    ID = row.ID,
                    Worker_ID = row.WorkerID,
                    AddressLine1 = row.Address_Line1 + " " + row.Address_Line2+ " " +row.City + " "+ GetLookupDisplayValById(row.State_LookID),
                    LogicalDelete = row.LogicalDelete

                };
                wlist.Add(ci);
            }


            return Json(wlist.ToList().OrderBy(p => p.AddressLine1), JsonRequestBehavior.AllowGet);
        }
Uncaught TypeError: Cannot call method 'toLowerCase' of undefined 
v.fn.extend.val                          jquery-1.8.3.min.js:2
(anonymous function)              $.each(address,function (index,currVal) {
v.extend.each                           jquery-1.8.3.min.js:2
(anonymous function)              currVal = $(this).val();
l                                 jquery-1.8.3.min.js:2
c.fireWith                        jquery-1.8.3.min.js:2
T                                 jquery-1.8.3.min.js:2
r