Jump to content
bravo14

AJAX call not working in iOS

Recommended Posts

Hi

 

I have an AJAX call that populates a select menu based on the selection from a previous menu.  All works on on desktop browser, Safari, Firefox IE etc, however when using iOS the second select menu isn't populating.

 

the AJAX request is as follows

 

 

<script>
function getXMLHTTP() { //fuction to return the xml http object
        var xmlhttp=false;
        try{
            xmlhttp=new XMLHttpRequest();
        }
        catch(e)    {
            try{
                xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch(e){
                try{
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                }
                catch(e1){
                    xmlhttp=false;
                }
            }
        }

        return xmlhttp;
    }



    function getTeam(strURL) {

        var req = getXMLHTTP();

        if (req) {

            req.onreadystatechange = function() {
                if (req.readyState == 4) {
                    // only if "OK"
                    if (req.status == 200) {
                        document.getElementById('away-team').innerHTML=req.responseText;
                    } else {
                        alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                    }
                }
            }
            req.open("GET", strURL, true);
            req.send(null);
        }

    }
        function getGP(strURL) {

        var req = getXMLHTTP();

        if (req) {

            req.onreadystatechange = function() {
                if (req.readyState == 4) {
                    // only if "OK"
                    if (req.status == 200) {
                        document.getElementById('gp').innerHTML=req.responseText;
                    } else {
                        alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                    }
                }
            }
            req.open("GET", strURL, true);
            req.send(null);
        }

    }
</script>
 
 

 

and the trigger for it...

 

<select name="year" class="txtfield" onChange="getGP('find_gp_ajax.php?season='+this.value)">

 

Any ideas why the call won't work on iOS?

Share this post


Link to post
Share on other sites

Your code seems OK. The only thing I can think of is that iOS has problems with the try & catch primer function. And why would you wanna use that anyway? IE8+ and all other browsers support XMLHttpRequest(), and coding for IE<8 is a waste of time, if you ask me. IE7 users can easily upgrade to 8, and IE6 has left the building. 

Share this post


Link to post
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

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.