My javascript isnt working

I have a simple javascript that is used for geo-ip location on a dating site.

It works perfectly when viewing the webpage from my local hard drive, and when viewing the same page from a hostgator account.

However, when uploaded to my Dreamhost account, it simply does not work… it acts as if the code is not there at all.

In the header, there is a call for the javascript like this:

And then further down in the page content, it is used like this:

What this does, is grabs a surfer’s city name and then later writes the city name in the page. Standard fare for a dating site.

Why does this not work with Dreamhost? Can it be fixed easily?

Do I need to move everything using a simple line of javascript to a different host? Surely not. Help please.

It does work at DreamHost.

testgeoip.html[code]

[/code]

Load your page and look at the source to make sure it’s printing to the browser correctly. Do you have any other js that might be stepping in the way?

Works for me:

[code]

you are in: [/code]

No one uses the [font=courier]language[/font] attribute any more.

Thanks, I’ll take that out and see what it does.
[hr]
Must be something else blocking it. I uploaded the code you wrote and it works… but on my page, it doesnt. Only other javascript there is a join form validator… just seems weird that the only place this doesnt work is at Dreamhost.

I found the problem.

Turned off “Page Speed Optimization” in the server settings for the domain, and now everything works perfectly.

Note to self: dont ever turn that crap on again

Hmm… I bet Page Speed was downloading the geoIP script for you and inlining it. Clever, but a little bit too clever in this case. :slight_smile:

That would definitely be stepping all over your stuff :wink:

PageSpeed should be renamed AGIDBETFBMAG :stuck_out_tongue:

I swear I saw a bit of code you could put in your JS calls to tell pagepseed to shove it… Apparently the only way is via disallows.

https://developers.google.com/speed/docs/mod_pagespeed/restricting_urls

So you’d want something like this in your .htaccess:

<IfModule pagespeed_module>
    ModPagespeed on
      ModPagespeedDisallow http://j.maxmind.com/app/geoip.js
</IfModule>