日期:2014-05-20  浏览次数:20765 次

求火狐中可用的ajax代码,可执行返回的java函数!
网上下了一个,据说可用在火狐中可用,但是实际测试下来好像不行。
现在的这个
function evalhtml(el, htmlCode)//ajax通用调用返回函数

//el:是插入的节点;
//htmlCode:是插入的代码
//下面的代码中,if为true部分在IE下是好用的,为false部分似乎无法执行回传的js函数。
var ua = navigator.userAgent.toLowerCase(); 
if (ua.indexOf('msie') >= 0 && ua.indexOf('opera') < 0) { 
htmlCode = '<div style="display:none">for IE</div>' + htmlCode; 
htmlCode = htmlCode.replace(/<script([^>]*)>/gi, 
'<script$1 defer>'); 
el.innerHTML = htmlCode; 
el.removeChild(el.firstChild); 
} else { 
var el_next = el.nextSibling; 
var el_parent = el.parentNode; 
el_parent.removeChild(el); 
el.innerHTML = htmlCode; 
if (el_next) { 
el_parent.insertBefore(el, el_next) 
} else { 
el_parent.appendChild(el); 




请大虾指教!

最好是带 插入点/插入代码 的这种函数!

------解决方案--------------------
JScript code

var XMLHttpReq;
     function createXMLHttpRequest() {
         if(window.XMLHttpRequest) { 
             XMLHttpReq = new XMLHttpRequest();
         } else if (window.ActiveXObject) { 
             try {
                  XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
              } catch (e) {
                  try {
                      XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
                  } catch (e) {}
              }
          }
  }

function findHotGift(num){
        var scoreLow = "";
        var scoreHigh = "";
        scoreLow = "0";
        scoreHigh = "20000";
        var url1 = "";
        if(num!=5){
            url1 = "<%=path%>/getHotSaleList.do?gc.scoreLow="+scoreLow+"&gc.scoreHigh="+scoreHigh+"&gc.lastIndex=6&timestamp="+Math.random();
        }else{
            url1 = "<%=path%>/getHotSaleList.do?gc.scoreLow="+scoreLow+"&gc.lastIndex=6&timestamp="+Math.random();
        }
      createXMLHttpRequest();
        XMLHttpReq.open("POST",url1,true);
        XMLHttpReq.setRequestHeader("cache-control","no-cache");
        XMLHttpReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        XMLHttpReq.onreadystatechange= function(){
            retHotGift();
        }
        XMLHttpReq.send(null);
    }
    function retHotGift(){
        if (XMLHttpReq.readyState == 4) { 
            if (XMLHttpReq.status == 200) { 
                var tagonediv = document.all.Tagonediv;
                tagonediv.innerHTML = XMLHttpReq.responseText;
            } else { 
                
            }
        }
    }