Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2006
    Posts
    399
    Thanks
    33
    Thanked 7 Times in 7 Posts

    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.

  • #2
    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
    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]

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,184
    Thanks
    10
    Thanked 569 Times in 550 Posts
    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==...)
    Last edited by rnd me; 05-11-2009 at 09:49 PM.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/1/19) IE7:0.2, IE8:6.7, IE11:7.4, IE9:3.8, IE10:4.4, FF:18.3, CH:43.6, SF:7.8, MOBILE:27.5


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •