仅在IE(8)中出现jQuery错误 – “对象不支持…”

我在jQuery中有这段代码( AJAX).
$.get('someScript.PHP?lat=' + clickedLatLng.lat() + '&lon=' + clickedLatLng.lng() + '&value=5',doSomething);

这是一个功能(在Google地图上显示一个图标并更改输入字段中的某些值).

function doSomething(data) {
    data = data.trim();
    data = data.split(","); 
    var stopName = data[0];
    var stopLat = data[1];
    var stopLon = data[2];

    $("#start").val(stopName);

    if (startMarker == null) {
        startMarker = new google.maps.Marker({
                            position: new google.maps.LatLng(stopLat,stopLon),map: map,zIndex: 2,title: stopName,icon: startimage 
        });
    } else {
        startMarker.setPosition(new google.maps.LatLng(stopLat,stopLon));
    }
}

但它适用于IE以外的所有浏览器,在我的IE 8中.我没有在IE 6/7中测试它.它弹出这个错误……

我查看了jquery.js,这是它​​打破的功能……

// resolve with given context and args
            resolveWith: function( context,args ) {
                if ( !cancelled && !fired && !firing ) {
                    firing = 1;
                    try {
                        while( callbacks[ 0 ] ) {
                            callbacks.shift().apply( context,args );
                        }
                    }
                    finally {
                        fired = [ context,args ];
                        firing = 0;
                    }
                }
                return this;
            },

其实

callbacks.shift().apply( context,args );

有人可以帮忙吗?问题出在哪儿?与jquery-1.4.4.js相同

编辑:这是我更大的代码……

// Set some events on the context menu links
contextMenu.find('a').click( function()
{
    // fade out the menu
    contextMenu.fadeOut(75);

    // The link's href minus the #
    var action = $(this).attr('href').substr(1);

    switch (action) {
        case 'startmenu':
            $.get('someScript.PHP?lat=' + clickedLatLng.lat() + '&lon=' + clickedLatLng.lng() + '&radijus=5',doSomethingWithData1);
            break;

        case 'stopMenu':
            $.get('someScript.PHP?lat=' + clickedLatLng.lat() + '&lon=' + clickedLatLng.lng() + '&radijus=5',doSomethingWithData2);    
            break;
    }

    return false;
});

用户点击Google地图上下文菜单中的项目时,请执行“doSomethingWithData1”和“doSomethingWithData2”.这也是上下文菜单的一些代码

// Hover events for effect
contextMenu.find('a').hover( function() {
    $(this).parent().addClass('hover');
},function() {
    $(this).parent().removeClass('hover');
});

这适用于AJAX

$.ajaxSetup ({  
        cache: false  
    });

这就是我包含jQuery脚本的方式.

<!-- Google Maps -->       
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

<!-- Load Javascript / jQuery -->
<script type="text/javascript" src="js/jquery-1.5.js"></script>
<script type="text/javascript" src="js/jquery.ui.core.js"></script>
<script type="text/javascript" src="js/jquery.ui.position.js"></script>
<script type="text/javascript" src="js/jquery.ui.widget.js"></script>
<script type="text/javascript" src="js/jquery.ui.autocomplete.js"></script>

<link rel="stylesheet" href="js/jquery.ptTimeSelect.css" type="text/css" media="all" />

<script type="text/javascript" src="js/jqtransformplugin/jquery.jqtransform.js"></script>
<link rel="stylesheet" href="js/jqtransformplugin/jqtransform.css" type="text/css" media="all" />

<script type="text/javascript" src="js/jquery.ui.datepicker.js"></script>

解决方法

这是= / – .trim() in JavaScript not working in IE

解决方案 – 在使用.trim函数之前添加它.

if(typeof String.prototype.trim !== 'function') {
  String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g,''); 
  }
}

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...