Jump to content

IE not updating


unplugged_web

Recommended Posts

I have a url (on a separate server with a different domain name) that gives me various parameters I need. I've managed to get the results, but for some reason it doesn't show any results at all in IE and I'm not sure why. It works in every other browser, but just not IE. I've checked the console and there's no errors at all, I've also used jslint.com to check the js code and that's all fine too. While I'm testing this I've removed everything else in the file so that there's nothing that can conflict with it. This is what I'm using to get the results. I have a separate js file that contains this:

/*jshint -W061 */function call(url, parameters, callback) {	"use strict";	$.ajax({		type: 'POST',		url: url,		data: parameters,		success: function(data) {			callback(data);		},  cache: false	}		);} function loadJackpots() {	"use strict";	call("https://www.domain.com/passkey", { JL: 0 },		function(data) {			var divIdentifier, obj = eval('(' + data + ')');			$.each(obj.JL, function() { 				divIdentifier = "";				switch (this.gameID) {				case 2:					divIdentifier = "#snap";					break;				case 5:					divIdentifier = "#dominos";					break;				case 1000:					divIdentifier = "#chess1";					break;				case 1001:					divIdentifier = "#chess2";					break;				case 1002:					divIdentifier = "#chess3";					break;				} 				if (this.gameID >= 1000) {					switch (this.stakeID) {					case 4:						divIdentifier += "_50c";						break;					case 5:						divIdentifier += "_1d";						break;					case 7:						divIdentifier += "_2d";						break;					case 9:						divIdentifier += "_2d";						break;					}				} 				if (this.gameID === 1000) {					switch (this.subID) {					case 0:						divIdentifier += "_1";						break;					case 1:						divIdentifier += "_2";						break;					case 2:						divIdentifier += "_3";						break;					}				}				$(divIdentifier).html("$" + this.jackpot);			});		}		 );}

I use this to actually load the values:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script><script type="text/javascript">		 $(function() {			loadJackpots();		});				</script>

And to display the results I'm using this:

<div id="chess1"><div id="chess1_50c">$1466.85</div><div id="chess1_1d">$1641.11</div><div id="chess1_2d">$378.04</div></div>  <div id="chess3"><div id="chess3_50c">$303.86</div><div id="chess3_1d">$523.02</div><div id="chess3_2d">$1473.72</div></div> </div><div style="float: left; margin: 194px 0 0 185px;"><div id="chess2_1"><div id="chess2_50c_1">$195.26</div><div id="chess2_1d_1">$154.37</div><div id="chess2_2d_1">$193.76</div></div><div id="chess2_2"><div id="chess2_50c_2">$146.84</div><div id="chess2_1d_2">$119.58</div><div id="chess2_2d_2">$145.86</div></div><div id="chess2_3"><div id="chess2_50c_3">$2.96</div><div id="chess2_1d_3">$19.25</div><div id="chess2_2d_3">$121.89</div></div> </div></div><div style="height: 80px;"><div id="snap"><div id="snap_jp">$862.16</div></div>  <div id="dominos"><div id="dominos_jp">$2823.18</div></div>

I've also tried this but to no avail, it just gave me an error saying obj is undefined:

<div id="dominos"><div id="dominos_jp">$2823.18</div><script language="javascript">document.getElementById("dominos_jp").HTML=obj.JL[1].jackpot</script></div>

I'd be really grateful for any help with this as I've tried everything to get it sorted, but no matter what I do it just won't work in IE. I read something about Ajax doesn't allow cross domain requests but I don't know how to rectify this - the values come from a url that is on another domain and I can't change that.

Edited by unplugged_web
Link to comment
Share on other sites

obj is only defined in the callback function for the ajax request, it's not global. But by default most browsers will not allow ajax requests to another domain, I don't know why it would work in any browser unless you changed the settings. If you need to load content from another domain then you need to use another solution, like a PHP proxy (send an ajax request to a PHP page on your server, PHP loads the remote content, and returns the result).

Link to comment
Share on other sites

obj is only defined in the callback function for the ajax request, it's not global. But by default most browsers will not allow ajax requests to another domain, I don't know why it would work in any browser unless you changed the settings. If you need to load content from another domain then you need to use another solution, like a PHP proxy (send an ajax request to a PHP page on your server, PHP loads the remote content, and returns the result).
I've been able to get the js file to be uploaded the to same domain as that the request is coming from, but it's still not working. If I save the results as a json file and test it on the same server as the site it works, but if I change where the results are coming from and then upload it all to the same server it still doesn't work. When I try this the only line that changes is this one:
        call("https://www.domain.com/passkey", { JL: 0 },

Edited by unplugged_web
Link to comment
Share on other sites

It's not the Javascript file that needs to be hosted on the remote server, it's the actual webpage. If the URL in your browser is pointing to domain.com, then you can only send ajax requests to domain.com, regardless of where you are loading the Javascript code from. If your page loads jQuery from api.google.com or wherever they host it, that doesn't mean you can send ajax requests to Google, it's still running on your page. If you need to load remote content then you need to use a proxy to get the content and give it to Javascript.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...