Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Ajax not sending in IE7

    Hi everyone.

    I am using the Ajax tutorial from ajaxfreaks, here is the JS:
    Code:
    <script type="application/javascript" language="javascript">
    function createRequestObject() {
       var req;
       if(window.XMLHttpRequest){
          // Firefox, Safari, Opera...
          req = new XMLHttpRequest();
       } else if(window.ActiveXObject) {
          // Internet Explorer 5+
          req = new ActiveXObject("Microsoft.XMLHTTP");
       } else {
          // There is an error creating the object,
          // just as an old browser is being used.
          alert('Problem creating the XMLHttpRequest object');
       }
       return req;
    }
    
    // Make the XMLHttpRequest object
    var http = createRequestObject();
    function sendRequest(act) {
    
       // Open PHP script for requests
       http.open('get', '_includes/_submit_airport.php?+act);
       http.onreadystatechange = handleResponse;
       http.send(null);
    
    }
    
    function handleResponse() {
    
       if(http.readyState == 4 && http.status == 200){
    
          // Text returned FROM the PHP script
          var response = http.responseText;
    
          if(response) {
             // UPDATE ajaxTest content
             document.getElementById("airportBox").innerHTML = response;
          }
       }
    }
    </script>
    And this is how I am using it:
    Code:
    <input type="button" name="submit" id="submit" value="Add" onClick="sendRequest('name=' + airport.name.value + '&country=' + airport.country.value + '&state=' + airport.state.value + '&city=' + airport.city.value + '&icao=' + airport.icao.value);" />
    So basically it sends some data which will eventually look like:
    _submit_airport.php?name=x&country=x&state=x... etc.

    Everything works flawlessly in Firefox, Opera, and Safari, but not in IE7 (haven't tried IE6 yet). All it says is that there is an error on the line of the second code I posted, Character 1, and the error is "Object Expected".

    Any ideas?
    Thanks

  • #2
    New Coder
    Join Date
    Dec 2007
    Posts
    14
    Thanks
    0
    Thanked 5 Times in 5 Posts
    Seems ok. The only error I get is

    Code:
    http.open('get', '_includes/_submit_airport.php?+act);
    where a ' is missing.

    Code:
    http.open('get', '_includes/_submit_airport.php?' + act);

  • #3
    New Coder
    Join Date
    Dec 2007
    Posts
    14
    Thanks
    0
    Thanked 5 Times in 5 Posts
    ok, the problem seems to be here

    Code:
    <script type="application/javascript" language="javascript">
    instead of

    Code:
    <script type="text/javascript" >
    don't' ask me why!
    Last edited by arilia; 01-02-2008 at 12:17 PM.

  • #4
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Hi,

    Sorry. The first missing tic mark was an error on my part copy and pasting. The actual code does have it.

    I took out the "language="javascript"" part and still does the same thing. Here is the URL, I am sure it will help:
    http://www.fszone.org/logbook/add/airport.php
    Last edited by fsstore.net; 01-02-2008 at 02:26 PM.

  • #5
    New Coder
    Join Date
    Dec 2007
    Posts
    14
    Thanks
    0
    Thanked 5 Times in 5 Posts
    the problem is not in language="javascript" (that is deprecated but not wrong)

    the question seems to be in

    type="application/javascript"

    instead of

    type="text/javascript"

  • Users who have thanked arilia for this post:

    fsstore.net (01-02-2008)

  • #6
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by arilia View Post
    the problem is not in language="javascript" (that is deprecated but not wrong)

    the question seems to be in

    type="application/javascript"

    instead of

    type="text/javascript"
    Whoops, sorry about that! Yeah, that was it! Thanks for the help, I would have never thought about looking there.
    Last edited by fsstore.net; 01-02-2008 at 02:44 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •