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 05-09-2009, 07:50 PM   PM User | #1
sybil6
Regular Coder

 
Join Date: Jul 2006
Posts: 399
Thanks: 33
Thanked 7 Times in 7 Posts
sybil6 can only hope to improve
my xhr does not work on ie

works perfect on safari and ff, thanks for your help
Code:
function xhr(){
var xmlHttp=null;
try{xmlHttp=new XMLHttpRequest();}
catch (e){
try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}


valid=new xhr();
function validation(){
var nom=document.forms.recommander_ce_blog.nom.value;
var email=document.forms.recommander_ce_blog.email.value;
var message=document.forms.recommander_ce_blog.message.value;
valid.onreadystatechange = alertContents;
valid.open('get',"validation_recommander_ce_blog.php?nom="+nom+"&email="+email+"&message="+message+"&id="+Math.random(), true);
valid.setRequestHeader('If-Modified-Since','Wed, 05 Apr 2006 00:00:00 GMT');
valid.send(null);

      }
function  alertContents(){
if (valid.readyState == 4) {
result = valid.responseText;
var div=document.getElementById('recommander_ce_blog_error_message')
div.innerHTML = result;
if (div.innerHTML=="<b>Merci!</b>"){
document.getElementById("recommander_ce_blog").style.display="none";
            }


      }
}


the form:

Code:
<form  action="javascript:validation()"  id="recommander_ce_blog" name="recommander_ce_blog" >
<table style="height: 148px;" border="0" width="282">
<tr>
<td>nom:</td>
<td><input name="nom" type="text" /></td>
</tr>
<tr>
<td>email:</td>
<td><input name="email" type="text" /></td>
</tr>
<tr>
<td valign="top">message:</td>
<td><textarea name="message"></textarea></td>
</tr>
<tr>
<td></td>
<td><input name="submit_recommander_ce_blog" type="submit" value="Submit" /></td>
</tr>
</table>
</form>

Last edited by sybil6; 05-09-2009 at 07:58 PM..
sybil6 is offline   Reply With Quote
Old 05-11-2009, 03:39 AM   PM User | #2
A1ien51
Senior Coder

 
A1ien51's Avatar
 
Join Date: Jun 2002
Location: Between DC and Baltimore In a Cave
Posts: 2,717
Thanks: 1
Thanked 94 Times in 88 Posts
A1ien51 will become famous soon enough
Have you added alert statements to figure out where it is breaking?

Do you have error message?

Eric
__________________
Tech Author [Ajax In Action, JavaScript: Visual Blueprint]
A1ien51 is offline   Reply With Quote
Old 05-11-2009, 09:46 PM   PM User | #3
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,468
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
move valid=new xhr(); into the function validation(), along with function alertContents()...

additionally, try assigning onreadystatechange after the .open(), not before.


also, .innnerHTML is not standardized, check against the string instead:
if (div.innerHTML==..) becomes if (result==...)
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%

Last edited by rnd me; 05-11-2009 at 09:49 PM..
rnd me 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 05:26 AM.


Advertisement
Log in to turn off these ads.