Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. issue with Ajax and IE

issue with Ajax and IE

Scheduled Pinned Locked Moved Web Development
toolshelpc++javascripthtml
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BeerFizz
    wrote on last edited by
    #1

    I'm using AJAX for the first time and while writing some code I noticed that IE appeared to be miss-behaving.   Attached below is the test case showing the issue.   This appears to fail with IE 6 and IE 7.   Works fine with firefox and chrome. In the code I have a number of alerts showing the path through the code and everything works ok until (with IE only) the call to the call back function setOutput.   With IE the second time the doAjax script is invoked, setOutput's never called (or at least there is never a ready state of 4). The way to reproduce this, is to delete IE's temporary internet files (tools/delete browsing history/temporary internet files).   Load the test script test.html.   Then click the "Click here" button and follow the path through.   The first time it works fine and SetOutput is indeed called.   If the button is clicked a second time, setOutput's never called.      You can repeat this procedure (deleting browser history and clicking "click here"). I tried deleting the ajaxObject object to see if that would help, but it did not. All help appreciated, Thanks Phil <code> ---------------- test.html -------------------------------------- <head> <script language="javascript" type="text/javascript"> <!-- var ajaxObj = null; function getAjaxObj() {             alert("getAjaxObj: Getting ajax object.");             alert("getAjaxObj: req is " + typeof req);       // native XMLHttpRequest object       if(window.XMLHttpRequest && !(window.ActiveXObject)) {                         alert("1");             try {                                     req = new XMLHttpRequest();                                     alert("1.1");             } catch(e) {                               &nbs

    L 1 Reply Last reply
    0
    • B BeerFizz

      I'm using AJAX for the first time and while writing some code I noticed that IE appeared to be miss-behaving.   Attached below is the test case showing the issue.   This appears to fail with IE 6 and IE 7.   Works fine with firefox and chrome. In the code I have a number of alerts showing the path through the code and everything works ok until (with IE only) the call to the call back function setOutput.   With IE the second time the doAjax script is invoked, setOutput's never called (or at least there is never a ready state of 4). The way to reproduce this, is to delete IE's temporary internet files (tools/delete browsing history/temporary internet files).   Load the test script test.html.   Then click the "Click here" button and follow the path through.   The first time it works fine and SetOutput is indeed called.   If the button is clicked a second time, setOutput's never called.      You can repeat this procedure (deleting browser history and clicking "click here"). I tried deleting the ajaxObject object to see if that would help, but it did not. All help appreciated, Thanks Phil <code> ---------------- test.html -------------------------------------- <head> <script language="javascript" type="text/javascript"> <!-- var ajaxObj = null; function getAjaxObj() {             alert("getAjaxObj: Getting ajax object.");             alert("getAjaxObj: req is " + typeof req);       // native XMLHttpRequest object       if(window.XMLHttpRequest && !(window.ActiveXObject)) {                         alert("1");             try {                                     req = new XMLHttpRequest();                                     alert("1.1");             } catch(e) {                               &nbs

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Hi The problem reported by you is a very genenal with IE. If you are making a AJAX call to server with same argument, then IE will not call the server page. It will display the previously fetched result. You can fix this bug with the little changes as: Every time you make a server call, send some Unique number along with the arguments. As you are just calling 'test.php' make the argument as test.php?rnd=<some random number> <some random number> : Replace it with Unique number. This will solve your problem. Simple way to generate the unique number id var dtDate = new Date(); var strDate = dtDate.getHours() + '' + dtDate.getMinutes() + '' + dtDate.getSeconds() + '' + dtDate.getMilliseconds(); Make a server call as test.php?rnd=strDate

      Regards Aman Bhullar www.arlivesupport.com[^]

      B 1 Reply Last reply
      0
      • L Lost User

        Hi The problem reported by you is a very genenal with IE. If you are making a AJAX call to server with same argument, then IE will not call the server page. It will display the previously fetched result. You can fix this bug with the little changes as: Every time you make a server call, send some Unique number along with the arguments. As you are just calling 'test.php' make the argument as test.php?rnd=<some random number> <some random number> : Replace it with Unique number. This will solve your problem. Simple way to generate the unique number id var dtDate = new Date(); var strDate = dtDate.getHours() + '' + dtDate.getMinutes() + '' + dtDate.getSeconds() + '' + dtDate.getMilliseconds(); Make a server call as test.php?rnd=strDate

        Regards Aman Bhullar www.arlivesupport.com[^]

        B Offline
        B Offline
        BeerFizz
        wrote on last edited by
        #3

        Aman Thank you so much for the very complete solution. Best Regards Phil

        P 1 Reply Last reply
        0
        • B BeerFizz

          Aman Thank you so much for the very complete solution. Best Regards Phil

          P Offline
          P Offline
          PrestonMB
          wrote on last edited by
          #4

          What I did is to build a small ajax library with a couple of commands that I use on a regular basis and then I had those commands automatically add the random information for me. Then, I never have to worry about that ever again :)

          Preston Tech Director / Developer MetalBuilding.com

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups