<\/script>')

JQuery error only in IE (8) - "Object does not support ..."

I have this piece of code (AJAX) in jQuery.

$.get('someScript.php?lat=' + clickedLatLng.lat() + '&lon=' + clickedLatLng.lng() + '&value=5', doSomething); 

And this is a function (shows an icon on Google Maps and changes some values ​​in the input fields).

 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)); } } 

But it works in all browsers except IE, in my case IE 8. I have not tested it in IE 6/7. He gives this error ...

jquery error in IE 8

I looked through jquery.js and this is the function it breaks in ...

  // 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; }, 

in fact

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

Can anyone help? What is the problem? Same thing with jquery-1.4.4.js

EDIT: This is my big code ...

  // Set some events on the context menu links contextMenu.find('a').click( function() { // fade out the menu contextMenu.fadeOut(75); // The link 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; }); 

When a user clicks on an item in the context menu on Google Maps, do " doSomethingWithData1 " and " doSomethingWithData2 ". This is also the code for the context menu.

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

and for AJAX

 $.ajaxSetup ({ cache: false }); 

This is how I included jQuery scripts.

  <!-- 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> 
+6
jquery ajax internet-explorer-8 google-maps
source share
2 answers

It was he = / - .trim () in JavaScript, which does not work in IE .

Solution - add this before using the .trim function.

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

The problem is that variable callbacks are not an array in this case. therefore callbacks.shift () fails

For a reason, call me paranoid, but try your code this way

 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); 
0
source share

All Articles