Jump to content


Photo

error in IE when using POST method in AJAX script


  • Please log in to reply
3 replies to this topic

#1 micah1701

micah1701
  • Members
  • PipPipPip
  • Advanced Member
  • 613 posts
  • LocationEllington, CT USA

Posted 07 July 2006 - 07:04 PM

In the past I've used AJAX quite a bit to send and receive data. Mostly, I'm sending small bits of data using the GET method (?GET=adding_the_variables_to_the_url).

I'm trying something new and want to send an entire form full of data, so I decided to use the POST method instead.  I thought I had it working, as I have been using it for a couple days now in FireFox, however, I just realized it doesn't work in Internet Explorer.

It returns the error "object doesn't support this property or method" for the line:
http.open("POST", "entryFormsubmit.php", true);

Again, it works in FF and doesn't throw any erros in the Fire Fox JavaScript console.
any idea what I'm missing?
Let me know if you need to see more code.

FYI...

the http object (referrenced above that "doesn't support the property or method" is built like this:
function getHTTPObject() 
{
 var xmlhttp; 
 /*@cc_on 
 @if (@_jscript_version >= 5) try { 
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } 
  catch (e) 
  { try 
  { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } 
  catch (E) 
  { xmlhttp = false; } 
  } 
  @else xmlhttp = false; @end 
  @*/ 
  
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') 
  { try { 
  xmlhttp = new XMLHttpRequest(); } 
  catch (e) 
  { xmlhttp = false; } 
  } 
  return xmlhttp; 

} //end getHTTPObject() function to create XMLHttpRequest Object

var http = getHTTPObject();

Thanks!!!
"Confidence in the face of risk."

#2 cmgmyr

cmgmyr
  • Members
  • PipPipPip
  • Advanced Member
  • 1,278 posts
  • LocationUSA

Posted 07 July 2006 - 07:47 PM

try taking ", true" out and see what happens

If that doesn't work, try changing "post" back to "get" and see what heppens.

-Chris

#3 micah1701

micah1701
  • Members
  • PipPipPip
  • Advanced Member
  • 613 posts
  • LocationEllington, CT USA

Posted 07 July 2006 - 08:03 PM

try taking ", true" out and see what happens


That solved it! thanks. 

I always thought the "true" was necessary though, so the script knew to wait for the readyState to change.  But it works fine w/o it.  eh, what do I know. Thats what I get for learning everything through online tutorials.

Thanks again!
"Confidence in the face of risk."

#4 cmgmyr

cmgmyr
  • Members
  • PipPipPip
  • Advanced Member
  • 1,278 posts
  • LocationUSA

Posted 08 July 2006 - 04:45 AM

hey, no problem, i'm glad it worked out for you.

-Chris




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users