Trouble retrieving variable in seperate javascript file in all versions of IE

Hello everyone,

In my page I have a function that takes in a parameter and passes that value to the jquery’s getScript function.
Here is an example


function getRoute(routeNumber){
   $.getScript('http://www.mySite.com/Scripts/Route' + routeNumber + '_trace.js',function(){
      var routeInfo = routeTrace // routeTrace is defined in the dynamically formed javascript.
   }
}


The javascript file being called would contain something as simple as this.


    var routeTrace = "96,bus,46.123456,96.123456";

In Firefox and Chrome, routeInfo does return the correct values. In IE6+, routeInfo returns undefined.
Obviously this is a cross browser issue and I went through numerous topics and found no solution.

Firefox and Chrome executes as expected with the callback function being called after the script has loaded.
IE6+ on the other hand behaves differently. Help is greatly appreciated.

Does the file your requesting exist on the same domain your script is running on? If not then that’s the reason why as cross domain requests are forbidden between 2 different domains.

Well, it’s on a different sub domain. This works fine in Chrome and FF though. In the meantime I’ll keep looking around.

I’m not getting any cross domain error either. Just says that routeTrace is undefined.

Update: I used bare minimum code on IE and it does work. It appears something else is affecting it. When i find it I’ll post it up. Thanks for your help.

Ahh IE needed the $.Trim() method on value I was passing. I’ll have to keep this in mind when working with other peoples data. :slight_smile: