471,887 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

my xhr does not work on ie

35
it works perfect on safari and ff but not on ie,any thoughts?, thanks for your help

Expand|Select|Wrap|Line Numbers
  1. function xhr(){
  2. var xmlHttp=null;
  3. try{xmlHttp=new XMLHttpRequest();}
  4. catch (e){
  5. try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
  6. catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  7.   }
  8.  }
  9. return xmlHttp;
  10. }
  11.  
  12.  
  13. valid=new xhr();
  14. function validation(){
  15. var nom=document.forms.recommander_ce_blog.nom.value;
  16. var email=document.forms.recommander_ce_blog.email.value;
  17. var message=document.forms.recommander_ce_blog.message.value;
  18. valid.onreadystatechange = alertContents;
  19. valid.open('get',"validation_recommander_ce_blog.php?nom="+nom+"&email="+email+"&message="+message+"&id="+Math.random(), true);
  20. valid.setRequestHeader('If-Modified-Since','Wed, 05 Apr 2006 00:00:00 GMT');
  21. valid.send(null);
  22.  
  23.       }
  24. function  alertContents(){
  25. if (valid.readyState == 4) {
  26. result = valid.responseText;
  27. var div=document.getElementById('recommander_ce_blog_error_message')
  28. div.innerHTML = result;
  29. if (div.innerHTML=="<b>Merci!</b>"){
  30. document.getElementById("recommander_ce_blog").style.display="none";

the form:
Expand|Select|Wrap|Line Numbers
  1. <form  action="javascript:validation()"  id="recommander_ce_blog" name="recommander_ce_blog" >
  2. <table style="height: 148px;" border="0" width="282">
  3. <tr>
  4. <td>nom:</td>
  5. <td><input name="nom" type="text" /></td>
  6. </tr>
  7. <tr>
  8. <td>email:</td>
  9. <td><input name="email" type="text" /></td>
  10. </tr>
  11. <tr>
  12. <td valign="top">message:</td>
  13. <td><textarea name="message"></textarea></td>
  14. </tr>
  15. <tr>
  16. <td></td>
  17. <td><input name="submit_recommander_ce_blog" type="submit" value="Submit" /></td>
  18. </tr>
  19. </table>
  20. </form>
May 10 '09 #1
6 1479
gits
5,390 Expert Mod 4TB
what exactly is not working in IE?

kind regards
May 10 '09 #2
arty
35
on ie i only get the first php validation error(nom wich is name) and it stuck there

php validation code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. Header('Cache-Control: no-cache');
  3. Header('Pragma: no-cache');
  4.  
  5. $nom=$_REQUEST["nom"];
  6. $email=$_REQUEST["email"];
  7. $message=$_REQUEST["message"];
  8.  
  9.  
  10. if(trim($nom)==""){
  11. print("un nom svp");
  12. }
  13. else if(trim($email)==""){
  14. print("un mail svp");
  15. }
  16. else if(!email_valid($email)){
  17.  print("un mail valide svp");
  18.     }
  19. else if(trim($message)==""){
  20.   print("un message svp");
  21. }
  22. else{
  23.  
  24. $to='dddd@gmail.com';
  25. $subject = 'nouveau message de votre site';
  26. $msg ='nom: '.$name.'<br />'.'Email: '.$email.'<br />'
  27. .'Message:'.nl2br($message);
  28. $headers='From:'.$email."\r\n".'Reply-To: '.$email."\r\n".'Return-Path: '.$email."\r\n".'Content-type: text/html; Charset=iso-8859-1';
  29. mail($to,$subject,$msg,$headers);
  30. print"<b>Merci!</b>";
  31.  
  32. }
  33.  
  34.  
  35.  
  36.  
  37. function email_valid ($email) {
  38. if (eregi("^[a-z0-9._-]+@[a-z0-9._-]+.[a-z]{2,4}$", $email))
  39.     { return TRUE; } else { return FALSE; }
  40. }
  41. ?>
May 10 '09 #3
arty
35
i changed to post method and it kinda solved the problem
May 10 '09 #4
gits
5,390 Expert Mod 4TB
glad to hear that you got it working ... even when it sounds strange ... did you receive the form's values correctly with GET?

kind regards
May 11 '09 #5
acoder
16,027 Expert Mod 8TB
Rather than using $_REQUEST, use $_GET or $_POST, so you can be sure nothing is overwritten.

According to the PHP code that you posted, only one error message can be printed at a time anyway.
May 11 '09 #6
arty
35
@gits
only the first form validation showed up(enter a name please) then it got stuck there(only for ie), the problem was very strange, the reason might be i am intergrating this into wordpress by trying to by pass everything related to wp, so the post method worked .
regards
May 11 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

14 posts views Thread by Anoop | last post: by
14 posts views Thread by webEater | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.