Results 1 to 8 of 8

Thread: X Browser AJAX

  1. #1
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default X Browser AJAX

    I have problems with an AJAX script with browsers other than IE or FF

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    </head>
    
    <body>
      <a href="ajax1.txt" class="popimg" type="AJAX" rev="ajaxcls" rel="file ajax1.txt"  >Ajax 1</a>
    <script type="text/javascript">
    /*<![CDATA[*/
    
    var Test={
    
     init:function(o){
       var cls=o.CommonClassName,clds=document.getElementsByTagName('A'),ary=[];
       for (var z0=0;z0<clds.length;z0++){
        if (this.cls(clds[z0],cls)){
         a=clds[z0];
         h=a.href.substring(a.href.lastIndexOf('/')+1);
         i=a.tabIndex||101;
         ary.push([a,a.href,null,null,a.rel||a.title,a.rev,i,'AJAX']);
        }
       }
       o={
        ary:ary,
        ld:1000
       }
       this.ajaxiframe(o);
    },
    
    
     cls:function (obj,nme){
      return new RegExp(' '+nme+' ').test(' '+obj.className+' ')
     },
    
    // Optional IFRAME and AJAX Code
     ajaxiframe:function(o){
      for (var iframe,z0=0,z1=0;z0<o.ary.length;z0++){
       if (typeof(o.ary[z0][1])=='string'){
        this.ajaxexit(o,o.ary[z0],new Date());
        this.ajax(o,o.ary[z0]);
        return
       }
      }
     },
    
     ajaxexit:function(o,ary,d){
      var oop=this;
      if (new Date()-d<o.ld){
       o.dly=setTimeout(function(){ oop.ajaxexit(o,ary,d); },200);
      }
      else {
       alert('Ajax File Not Found\n'+ary[1].substring(ary[1].lastIndexOf('/')+1));
       ary[1]=false;
       this.ajaxiframe(o);
      }
     },
    
     ajax:function(o,ary){
      var oop=this,html=false;
      if (window.ActiveXObject){
       try {
        html=new ActiveXObject("Msxml2.XMLHTTP");
       }
       catch (e){
        try {
         html=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e){
        }
       }
      }
      else if (window.XMLHttpRequest){
       html=new XMLHttpRequest();
      }
      else {
       return false;
      }
      html.onreadystatechange=function(){ oop.ajaxpopulate(o,ary,html); }
      html.open('GET',ary[1]+'?'+new Date().getTime(),true);
      try {
       html.send(null);
      }
      catch (e){
      }
     },
    
     ajaxpopulate:function(o,ary,html){
      if (html.readyState==4&&(html.status==200||window.location.href.indexOf("http")==-1)){
       html=html.responseText;
       if (o&&html){
        clearTimeout(o.dly);
        ary[1]=document.createElement('DIV');
        ary[1].innerHTML=html;
        ary[1].className=ary[0].rev;
        this.ajaxiframe(o);
        alert(html);
       }
      }
     }
    
    }
    
    Test.init({
     CommonClassName:'popimg'   //(optional) the common class name of the links defining the elements to view.     (string, default = images defined by array)
    
    });
    /*]]>*/
    </script>
    </body>
    
    </html>
    ajax1.txt

    Code:
     The script allows elements to be displayed in a Pop Up.<br>
     These elements may be:<br>
      IMAGEs,<br>
      HTML coded DIVs,<br>
      IFRAMEs,<br>
      AJAX elements<br>
      or images defined by an array.<br>
     <br>
     The Pop Up is displayed in the center of the page<br>
     on top of an optional 'mask' covering the rest of the page content.<br>
     <br>
     Optional animation allow the Pop Up the be animated open and closed<br>
     and the slide show images to be faded in.<br>
    
     The Pop Up is defined in the HTML code to provide the maximum flexibility.<br>
     <br>
     The elements are displayed in a 'frame' DIV<br>
     <br>
     An optional control DIV allows the display of:<br>
      slideshow control elements,<br>
      captions,<br>
      a pageing indicator<br>
      and pagination.<br>
     <br>
     Optional persistence restores the last Pop Up on page load.
     <br>
     <br>
    any help will be appreciated
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Is there an X browser? If you mean Chrome, it doesn't do AJAX locally. If you want more help I will test out the code in a browser for you if I know what browser you mean and I have it. Better yet, tell me the browser and link to a live test page.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    vwphillips (01-03-2013)

  4. #3
    Join Date
    Jul 2008
    Posts
    128
    Thanks
    0
    Thanked 17 Times in 16 Posts

    Default

    What is the exact nature of the problem, and what is preventing you debugging it?

  5. #4
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    If you mean Chrome, it doesn't do AJAX locally.
    that seems to be the problem

    test page

    http://www.vicsjavascripts.org.uk/Ma...r/ajaxtest.htm
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  6. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The script doesn't appear to do anything any differently in any browser (tested in IE 9 in IE 9 and IE 8 modes, Opera, Chrome, and Firefox). When the page first loads there's an alert that has the contents of the external page (ajax.txt) in it. If I click on the link (Ajax 1), I'm taken to that page.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #6
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  8. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    In Chrome, when I first loaded the page I got an error "ms is not defined" on this line:

    Code:
     load:function(o,d){
      for (var oop=this,z0=0,z1=0;z0<o.ary.length;z0++){
       if (o.ary[z0][3]&&o.ary[z0][3].width<40&&new Date()-o.ld<ms){
        o.dly=setTimeout(function(){ oop.load(o,d); },200);
        return;
       }
      }
      for (;z1<o.ary.length;z1++){
       if ((o.ary[z1][3]&&o.ary[z1][3].width<40)||o.ary[z1][1]===false){
        o.ary.splice(z1--,1);
       }
      }
      o.ary[0]?this.ready(o,o.ary):null;
     },
    And the Ajax 1 link took me to the page. After I hit the back button, if I clicked on Ajax 1 or Ajax 2 I got a nice popup with the text in it.

    I then tried clearing the cache and history to see if I could duplicate the problem. I could not. It performed fine. So I'm thinking that first time was a bit of a fluke, perhaps the network was slow. But it might be something more. Even if it's just that, there's probably a way to determine if ms is undefined and to go back and define it before proceeding and/or have a default value for it, rather than throw an error.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #8
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    line corrected to

    Code:
       if (o.ary[z0][3]&&o.ary[z0][3].width<40&&new Date()-d<o.ld){
    If the image has not loaded after o.ld milli seconds the field with the image is removed


    Thanks
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

Similar Threads

  1. Browser back button with dynamic ajax content
    By dmelnyk in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 05-07-2011, 01:30 AM
  2. Dynamic Ajax Content - browser back
    By tomkorver in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 11-22-2009, 05:02 PM
  3. Replies: 2
    Last Post: 11-22-2008, 01:46 PM
  4. Dynamic Ajax Content, but with browser functions?
    By Quizosde in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 08-18-2008, 07:43 PM
  5. [DHTML] Cross browser method (1Kb of code) to upload files using AJAX
    By justas in forum Submit a DHTML or CSS code
    Replies: 0
    Last Post: 12-06-2006, 04:53 PM

Bookmarks

Posting Permissions

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