日期:2014-05-16  浏览次数:20367 次

同一个事件在不同的点击中只能触发一次
,我要做的就是点击“+”的时候触发一次事件,但是在别的"+"号那里可以用,不懂我的问题,可以在回复中说


function onclickBusiness(id){
if(id){
var xmlhttp=create();
xmlhttp.open("post","servlet/AjaxService");
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState==4){
        if(xmlhttp.status==200){
var doc=xmlhttp.responseXML.documentElement;
var rows = doc.getElementsByTagName("row");
var div = document.createElement("div");
div.setAttribute("style","margin-left:140px;font-size:12px;");
var imgid=$(id);//得到在那里在实现一个层
for(var i = 0;i<rows.length;i++){
var r = rows[i];//得到行
var i1=r.childNodes[0].firstChild.nodeValue;//得到编号
var i2=r.childNodes[1].firstChild.nodeValue;//得到名称
var i3=r.childNodes[2].firstChild.nodeValue;//得到父编号
var p=document.createElement("p");
var input =document.createElement("input");
input.value=i2;
input.name="checks";
p.setAttribute("style","margin-top:3px;");
input.type="checkbox";
p.innerHTML=i2;
div.appendChild(p);
p.appendChild(input);
$(id).style.display="block";
}
alert(i1);
imgid.appendChild(div);
}else{
alert("错误:"+xmlhttp.status);
};
};
};
xmlhttp.send("m=selectBusiness&&id="+id);

}

}
只是我的代码
------解决方案--------------------
你也觉得我们会看不懂你的意思啊,LZ英明
------解决方案--------------------
建议你讲业务,直接说要实现什么功能
------解决方案--------------------
说实话,实在不明白LZ在说什么
------解决方案--------------------
你判断下容器是否有内容不就行了,没有就执行ajax,有就返回

function onclickBusiness(id) {
    if (id) {
        var imgid = $(id); //得到在那里在实现一个层//////////获取容器的地方钓上来
        if (imgid.innerHTML != '') return////已经执行过ajax有内容,直接返回
        var xmlhttp = create();
        xmlhttp.open("post", "servlet/AjaxService");
        xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4) {
                if (xmlhttp.status == 200) {
                    var doc = xmlhttp.responseXML.documentElement;
                    var rows = doc.getElementsByTagName("row");
                    var div = document.createElement("div");
                 &n