Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-02-2008, 03:50 AM   PM User | #1
fsstore.net
New to the CF scene

 
Join Date: Dec 2005
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
fsstore.net is an unknown quantity at this point
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
fsstore.net is offline   Reply With Quote
Old 01-02-2008, 10:51 AM   PM User | #2
arilia
New Coder

 
Join Date: Dec 2007
Posts: 14
Thanks: 0
Thanked 5 Times in 5 Posts
arilia is an unknown quantity at this point
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);
arilia is offline   Reply With Quote
Old 01-02-2008, 11:09 AM   PM User | #3
arilia
New Coder

 
Join Date: Dec 2007
Posts: 14
Thanks: 0
Thanked 5 Times in 5 Posts
arilia is an unknown quantity at this point
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 11:17 AM..
arilia is offline   Reply With Quote
Old 01-02-2008, 01:24 PM   PM User | #4
fsstore.net
New to the CF scene

 
Join Date: Dec 2005
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
fsstore.net is an unknown quantity at this point
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 01:26 PM..
fsstore.net is offline   Reply With Quote
Old 01-02-2008, 01:30 PM   PM User | #5
arilia
New Coder

 
Join Date: Dec 2007
Posts: 14
Thanks: 0
Thanked 5 Times in 5 Posts
arilia is an unknown quantity at this point
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"
arilia is offline   Reply With Quote
Users who have thanked arilia for this post:
fsstore.net (01-02-2008)
Old 01-02-2008, 01:37 PM   PM User | #6
fsstore.net
New to the CF scene

 
Join Date: Dec 2005
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
fsstore.net is an unknown quantity at this point
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 01:44 PM..
fsstore.net is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:49 PM.


Advertisement
Log in to turn off these ads.