Jump to content

AJAX call not working in iOS


bravo14

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?

Link to comment
https://forums.phpfreaks.com/topic/288568-ajax-call-not-working-in-ios/
Share on other sites

  • 2 weeks later...

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. 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

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.