views:

17

answers:

0

Hey all!

Developing a mobile site on the side. Our target audiences include Android operating systems, iPhone OS (now iOS), WebOS, Windows Mobile, Blackberry (Curve, Tour, Bold), and the Nokia N95.

Pretty much all of these devices save for the Blackberry Curve have Ajax support. The Nokia N95, however, has Ajax support, but I'm having zero luck of it loading an external JavaScript. I've thrown alerts into this external JavaScript file, and none of them fire. I've created links, and tried onclick events that fire functions in this external JavaScript file to no avail.

I've tried different syntaxes for the onclicks, like so:

onclick="Test();"
onclick="Test(); return false;"
onclick="javascript:Test();"
onclick="javascript:Test();return false;"

However, no dice. Here's my include:

<script type="text/javascript" language="javascript" src="/includes/global.js" ></script>

And my doc-type/head:

<?xml version="1.0" encoding="UTF-8"?>

Any ideas? For what it's worth, I'm trying to keep the site as lean as can be, so no jQuery or prototype.

I created a function in my global.js as such:

function GetXHR() {
if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
    return true;
} else try {
    req = new ActiveXObject('Msxml2.XMLHTTP');
    return true;
} catch (e) {
    try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        return true;
    } catch (e) {
        req = false;
        return false;
    }
}

}

And an example of a function using it:

function GetVehicleMakes() {
var year = document.getElementById("year").value;
if (GetXHR()) {
    req.open("GET", "/ajax/GetVehicleMakes?year=" + year, true);
    req.onreadystatechange = function() {
        if (req.readyState == 4) {
            if (req.status == 200) {
                document.getElementById("make").innerHTML = req.responseText;
            }
        }
    }
    req.send();
}

}

Any ideas?