Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
仅在IE(8)中出现jQuery错误;对象没有';“我不支持……”;_Jquery_Ajax_Google Maps_Internet Explorer 8 - Fatal编程技术网

仅在IE(8)中出现jQuery错误;对象没有';“我不支持……”;

仅在IE(8)中出现jQuery错误;对象没有';“我不支持……”;,jquery,ajax,google-maps,internet-explorer-8,Jquery,Ajax,Google Maps,Internet Explorer 8,我在jQuery中有这段代码(AJAX) $.get('someScript.php?lat=' + clickedLatLng.lat() + '&lon=' + clickedLatLng.lng() + '&value=5', doSomething); 这是一个函数(在谷歌地图上显示一个图标,并更改输入字段中的一些值) 但它在除IE之外的所有浏览器中都能工作,在我的例子中是IE 8。我没有在IE 6/7中测试它。它弹出了这个错误 我查看了jquery.js,这就是它中

我在jQuery中有这段代码(AJAX)

$.get('someScript.php?lat=' + clickedLatLng.lat() + '&lon=' + clickedLatLng.lng() + '&value=5', doSomething);
这是一个函数(在谷歌地图上显示一个图标,并更改输入字段中的一些值)

但它在除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;
});
当用户单击谷歌地图上的上下文菜单中的项目时,请执行“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>

问题在于,在这种情况下,变量回调不是数组。因此callbacks.shift()失败

至于原因,请叫我偏执狂,但这样试试你的代码

var url = 'someScript.php?lat=' + clickedLatLng.lat() + '&lon=' + clickedLatLng.lng() + '&value=5';
$.get(url,function(data){
console.log(data);
});

//if the above worked then try this
$.get(url, doSomething);
这就是它

解决方案-在使用.trim函数之前添加此选项

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

如果您在
jquery.js
文件中遇到错误,99.9999%的时间都是因为您的代码有问题。查看一下。你能提供你是如何在HTML标记中引用jQuery.js的吗?另外,你在加载页面时有没有发现错误?…或者在回调函数中有没有发现错误?你的回调真的被调用了吗?我建议在
setPosition
回调的第一行设置一个断点,然后单步执行。查看生成的
数据
,确保其有意义。找出哪一行代码实际上失败了(您引用的jQuery行只是调用您的回调;更可能的是错误出现在回调中)。不要忘记接受您自己的答案,这样将来任何人都可以一眼看到解决方案。
if(typeof String.prototype.trim !== 'function') {
  String.prototype.trim = function() {
    return this.replace(/^\s+|\s+$/g, ''); 
  }
}