Current location: Hot Scripts Forums » General Web Coding » JavaScript » ajax and firefox


ajax and firefox

Reply
  #1 (permalink)  
Old 07-13-08, 04:39 PM
naissa naissa is offline
Wannabe Coder
 
Join Date: Jul 2004
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
ajax and firefox

I'm using the following code:
JavaScript Code:
  1. <script type="text/javascript">
  2.         function ajaxFunction(url)
  3.         {
  4.             var xmlHttp;
  5.             try
  6.             {
  7.                 // Firefox, Opera 8.0+, Safari
  8.                 xmlHttp=new XMLHttpRequest();
  9.             }
  10.             catch (e)
  11.             {
  12.                 // Internet Explorer
  13.                 try
  14.                 {
  15.                     xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  16.                 }
  17.                 catch (e)
  18.                 {
  19.                     try
  20.                     {
  21.                         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  22.                     }
  23.                     catch (e)
  24.                     {
  25.                         alert("Your browser does not support AJAX!");
  26.                         return false;
  27.                     }
  28.                 }
  29.             }
  30.             xmlHttp.onreadystatechange=function()
  31.             {
  32.                 if(xmlHttp.readyState==4)
  33.                 {
  34.                     document.getElementById("result").innerHTML = xmlHttp.responseText;
  35.                 }
  36.             }
  37.             xmlHttp.open("GET",url,true);
  38.             xmlHttp.send(null);
  39.         }
  40.         </script>

but for some reason ajaxFunction is not working properly on firefox.

thoughts??

Last edited by TwoD; 07-13-08 at 05:34 PM. Reason: Please remember [highlight=JavaScript][/highlight]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-13-08, 05:40 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
Any errors in the Console? (Ctrl+Shift+J) If so, please post the entire error and mark the line where it appears.

I can't see any obvious syntax problems so it's probably something else.

Btw, if you'd like to be able to not think about xmlHttpRequest incompatibilities between browsers, I can recommend using Re-inventing XMLHttpRequest: Cross-browser implementation with sniffing capabilities by Sergey Ilinsky. It creates a cross-browser implementation of the xmlHttpRequest object and fixes a bunch of bugs which appear in only some browsers. It also has great logging capabilities which are easy to enable/disable by simply adding/removing a few prototyped functions.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-17-08, 07:20 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
You might want to consider a toolkit like dojo, jQuery, script??us, prototype, etc for the AJAX functionality.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
AJAX Post an Array trouble scott2500uk JavaScript 9 11-30-09 11:39 AM
Date updating of a calendar with PHP and AJAX. miniature PHP 1 11-02-07 01:31 AM
ajax or css i dont know mjr JavaScript 2 03-02-07 12:37 PM
AJAX works in IE not in firefox srustiranjan JavaScript 1 06-04-06 09:32 AM


All times are GMT -5. The time now is 08:52 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.