IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

AJAX Discussion :

[AJAX] httprequest avec ie9


Sujet :

AJAX

  1. #1
    Candidat au Club
    Profil pro
    Inscrit en
    Août 2007
    Messages
    1
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 1
    Points : 2
    Points
    2
    Par défaut [AJAX] httprequest avec ie9
    J'ai un problème avec se code qui ne rafraichi pas la page si sous IE9
    j'Ai tester les autre.. mozilla.. chrome.. opera et ils fonctionnent tous.
    par contre sous IE9 rien ne se rafraichi. Quelqu'un aurait une solution a me proposer?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    <?php
    if($pokerpage==1)
    {
    $extrapokerheaders="
    
    <META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">
    <META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\">
    ";
            $pokerjs="
    
    <script type=\"text/javascript\">
    var f = false;
    var doitagain = true;
    var waittime = 5000;
    var pauserefresh = false;
    
    function postFormAjax(url, formname)
    {
            var xmlhttp;
    
            try {
                    //Cool browsers
                    xmlhttp = new XMLHttpRequest();
            } catch (e) {
    
                    //Internet Explorer
                    try {
                            xmlhttp = new ActiveXObject(\"Msxml2.XMLHTTP\");
                    } catch (e) {
                            try {
                                    xmlhttp = new ActiveXObject(\"Microsoft.XMLHTTP\");
                            } catch (e) {
                                    alert('We cannot initiate ajax, please update your browser.');
                            }
                    }
            }
    
    
      if (!f && xmlhttp)
      {
        var fields = new Array();
        if(formname)
            {
          var ajax = formname;
        }
        //loop through form elements and retrieve field NAMEs and Values
        for (var x = 0; x < eval(\"document.\"+ajax+\".elements.length\"); x++)
            {
    
         // join them into a string.
     eval(\"fields.push(document.\"+ajax+
    \".elements[x].name+'='+document.\"
    +ajax+\".elements[x].value)\");
    
        }
        elem = 'errors';
    
        var sendf = fields.join('&');
    
        xmlhttp.open(\"POST\", url, true);
        xmlhttp.onreadystatechange = function()
            {
              if (xmlhttp.readyState == 4)
              {
                if(xmlhttp.status == 200)
                {
                  results = xmlhttp.responseText;
                  var para = document.getElementById('errors');
                  para.innerHTML = results;
                  f = false; // re activate the AJAX function
    
                            //refresh page
                            //clearTimeout();
                            pauserefresh=false;
                            refreshPokerOnce();
                            refreshPokerChat();
                }
              }
            }
    
    
        xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xmlhttp.send(sendf);
        f = true;
            if(formname=='postchat'){document.getElementById(\"chattxtinput\").value = '';}
      }
    }
    
    function enter_pressed(e)
    {
            var keycode;
            if (window.event) keycode = window.event.keyCode;
            else if (e) keycode = e.which;
            else return false;
            return (keycode == 13);
    }
    
    function beginPokerAjax()
    {
    
            refreshEverything();
    }
    
    function setMaxBet(input)
    {
            var xmlhttp;
            var maxbetamount = 0;
            var maxbetamount2 = 0;
    
            try {
                    //Cool browsers
                    xmlhttp = new XMLHttpRequest();
            } catch (e) {
    
                    //Internet Explorer
                    try {
                            xmlhttp = new ActiveXObject(\"Msxml2.XMLHTTP\");
                    } catch (e) {
                            try {
                                    xmlhttp = new ActiveXObject(\"Microsoft.XMLHTTP\");
                            } catch (e) {
                                    alert('We cannot initiate ajax, please update your browser.');
                            }
                    }
            }
            xmlhttp.onreadystatechange=function()
            {
            if(xmlhttp.readyState==4)
              {
                            maxbetamount = xmlhttp.responseText;
                            maxbetamount2 = maxbetamount-input;
                      document.getElementById(\"betamnt\").value = maxbetamount2;
              }
            }
    
            xmlhttp.open(\"GET\",\"pokerdataajax.php?id=1\",true);
            xmlhttp.send(null);
            pauserefresh=true;
    
    }
    
    
    function typingBet()
    {
            pauserefresh=true;
    }
    
    function runPokerAjax()
    {
    
            //every x seconds, resend the ajax
            clearTimeout();
            if(doitagain)
            {
                    doitagain=false;
                    var t=setTimeout(\"refreshEverything()\",waittime);
            }
    }
    
    
    function refreshEverything()
    {
            refreshPokerChat();
            refreshPoker();
            doitagain=true;
    }
    
    
    
    function runPokerViewAjax(para)
    {
            //every x seconds, resend the ajax
            clearTimeout();
            var t=setTimeout(\"beginPokerViewAjax(\"+para+\")\",waittime);
    }
    
    function beginPokerViewAjax(para)
    {
    
            var xmlhttp;
    
            try {
                    //Cool browsers
                    xmlhttp = new XMLHttpRequest();
            } catch (e) {
    
                    //Internet Explorer
                    try {
                            xmlhttp = new ActiveXObject(\"Msxml2.XMLHTTP\");
                    } catch (e) {
                            try {
                                    xmlhttp = new ActiveXObject(\"Microsoft.XMLHTTP\");
                            } catch (e) {
                                    alert('We cannot initiate ajax, please update your browser.');
                            }
                    }
            }
            xmlhttp.onreadystatechange=function()
            {
            if(xmlhttp.readyState==4)
              {
                      document.getElementById(\"pokerdivview\").innerHTML = '';
                      document.getElementById(\"pokerdivview\").innerHTML = xmlhttp.responseText;
              }
            }
    
            xmlhttp.open(\"GET\",\"pokerviewoutput.php?t=\"+para,true);
            xmlhttp.send(null);
            runPokerViewAjax(para);
    }
    
    function refreshPoker()
    {
            if(!pauserefresh)
            {
                    var xmlhttp;
    
                    try {
                            //Cool browsers
                            xmlhttp = new XMLHttpRequest();
                    } catch (e) {
    
                            //Internet Explorer
                            try {
                                    xmlhttp = new ActiveXObject(\"Msxml2.XMLHTTP\");
                            } catch (e) {
                                    try {
                                            xmlhttp = new ActiveXObject(\"Microsoft.XMLHTTP\");
                                    } catch (e) {
                                            alert('We cannot initiate ajax, please update your browser.');
                                    }
                            }
                    }
                    xmlhttp.onreadystatechange=function()
                    {
                    if(xmlhttp.readyState==4)
                      {
                              document.getElementById(\"pokerdiv\").innerHTML = '';
                              document.getElementById(\"pokerdiv\").innerHTML = xmlhttp.responseText;
                      }
                    }
    
                    xmlhttp.open(\"GET\",\"pokeroutput.php\",true);
                    xmlhttp.send(null);
            }
            pauserefresh=false;
            runPokerAjax();
    }
    
    function refreshPokerOnce()
    {
            var xmlhttp;
    
            try {
                    //Cool browsers
                    xmlhttp = new XMLHttpRequest();
            } catch (e) {
    
                    //Internet Explorer
                    try {
                            xmlhttp = new ActiveXObject(\"Msxml2.XMLHTTP\");
                    } catch (e) {
                            try {
                                    xmlhttp = new ActiveXObject(\"Microsoft.XMLHTTP\");
                            } catch (e) {
                                    alert('We cannot initiate ajax, please update your browser.');
                            }
                    }
            }
            xmlhttp.onreadystatechange=function()
            {
            if(xmlhttp.readyState==4)
              {
                      document.getElementById(\"pokerdiv\").innerHTML = '';
                      document.getElementById(\"pokerdiv\").innerHTML = xmlhttp.responseText;
              }
            }
    
            xmlhttp.open(\"GET\",\"pokeroutput.php\",true);
            xmlhttp.send(null);
    }
    
    
    function refreshPokerChat()
    {
            var xmlhttp;
    
            try {
                    //Cool browsers
                    xmlhttp = new XMLHttpRequest();
            } catch (e) {
    
                    //Internet Explorer
                    try {
                            xmlhttp = new ActiveXObject(\"Msxml2.XMLHTTP\");
                    } catch (e) {
                            try {
                                    xmlhttp = new ActiveXObject(\"Microsoft.XMLHTTP\");
                            } catch (e) {
                                    alert('We cannot initiate ajax, please update your browser.');
                            }
                    }
            }
            xmlhttp.onreadystatechange=function()
            {
            if(xmlhttp.readyState==4)
              {
                      document.getElementById(\"pokerchat\").innerHTML = xmlhttp.responseText;
              }
            }
    
            xmlhttp.open(\"GET\",\"pokerchatoutput.php\",true);
            xmlhttp.send(null);
    
    }
    
    </script>
    ";
    }
    ?>

  2. #2
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut
    Bonjour,

    Montre nous le code js généré mais pas le code php.
    Essaie de remplacer
    eval(\"document.\"+ajax+\".elements.length\")
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    document.forms[ajax].elements.length
    .
    De même pour les autres.

    A+.

Discussions similaires

  1. Réponses: 1
    Dernier message: 05/07/2012, 17h18
  2. [AJAX] Souci avec HTTPRequest sous IE en SSL
    Par DjChat dans le forum Général JavaScript
    Réponses: 0
    Dernier message: 04/03/2009, 11h21
  3. AJAX : Problème avec les accents...
    Par @drien dans le forum XML/XSL et SOAP
    Réponses: 2
    Dernier message: 29/01/2006, 14h33
  4. [AJAX] Problèmes avec les caractères accentués
    Par marti dans le forum Servlets/JSP
    Réponses: 10
    Dernier message: 26/10/2005, 14h10

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo