Jump to content

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. 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.