Hi Shawn,

I have been playing with your code and learning about Ajax. It works great for IE, but I have been trying to make it work for Firefox.

I replace your
var xmlHttp = new ActiveXObject("Microsoft.XmlHttp");
with
var xmlHttp = createRequestObject();

where :

function createRequestObject() {
 var request;
 try {
   request = new ActiveXObject("Msxml2.XMLHTTP");
 } catch(e) {
   try {
     request = new ActiveXObject("Microsoft.XMLHTTP");
   } catch(f) {
     request = null;
   }
 }
 if(!request && typeof XMLHttpRequest != "undefined") {
   request = new XMLHttpRequest();
 }
 return request;
}

It still works with IE, but not with Firefox, watching with venkman it gets to
 request = new XMLHttpRequest();

But when Open is called it fires the catch error handler. Have not been able to figure this out yet. Any experience with doing this for Firefox?

Cheers, Tom.

Shawn K. Hall wrote:
This is some code I've migrated
from one of my homebrew samples. Save it as a new htm file:

'// ========================================================
<html>
<head>

<title> Test </title>

<script language="javascript">

var ksRoot = "http://www.userfriendly.org/cartoons/";;

function showImage( sImage ){
        var s = '';
        try{
        //attempt to obtain the content
          var sUrl  = "http://ars.userfriendly.org/cartoons/?id="; +
sImage;
          var xmlHttp = new ActiveXObject("Microsoft.XmlHttp");
          xmlHttp.open("GET", sUrl, false);
          xmlHttp.send();

        //get the response content from the remote site
          var sBody = xmlHttp.responseText;
          var rx = /(\/archives\/[0-9a-zA-Z]+\/uf[\d]+\.gif)/g;
//3456789`123456789`123456789`123456789`123456789`123456789`123456789`
          var r; var i = 0;
          if ((r = rx.exec(sBody)) != null){
            sParsed = r[1];
          }
          sParsed = sParsed.substr(1);

        }catch(e){
          alert( "It didn't work!" + "\n" + e.number + "::" +
e.description);
        }

        var o = document.getElementById('testimg');
        o.src = ksRoot + sParsed;
}

</script>

</head>
<body>

<img src="http://12pointdesign.com/stock/images/ra-button.gif";
id="testimg" /> <br />

<a onclick="javascript:showImage('20060120');"> 20060120 </a> <br />
<a onclick="javascript:showImage('20060121');"> 20060121 </a> <br />
<a onclick="javascript:showImage('20060122');"> 20060122 </a> <br />
<a onclick="javascript:showImage('20060123');"> 20060123 </a> <br />

</body>
</html>
'// ========================================================


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
To unsubscribe visit:
https://lists.sourceforge.net/lists/listinfo/dqsd-users
DQSD-Users@lists.sourceforge.net
http://sourceforge.net/mailarchive/forum.php?forum_id=8601

Reply via email to