llyzlc
llyzlc
  • 发布:2014-12-30 09:15
  • 更新:2014-12-30 09:15
  • 阅读:1939

onclick事件没反应

分类:HTML5+

var divsonimg2 = document.createElement("img");
divsonimg2.className = "details-img";
if (jsondata[i].agree == "no") {
divsonimg2.src = "../img/btn_agree_normal.png"
}
if (jsondata[i].agree == "yes") {
divsonimg2.src = "../img/btn_agree_pressed.png"
}
divsonimg2.addEventListener('click', function() {
console.log("ergdfgw");
var url = "http://120.236.234.222/dz25/app/good.php?tid=" + tid;
var xhr = new XMLHttpRequest();
var strdata = "";
var parm = "sid=" + returnItem("sessionid");
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
strdata = xhr.responseText.replace(/\x0a|\x0d/g, "");;
console.log(strdata);
//var jsondata2 = eval('(' + strdata + ')').datas;
var jsoncode2 = eval('(' + strdata + ')').code;
if (jsoncode2 == "200") {
mui.toast(jsondata[0].info);
this.src = "../img/btn_agree_pressed.png";
}
if (jsoncode2 == "404") {
mui.toast(jsondata[0].info);
}
}
}
xhr.send(parm);

				});  
				lisondiv2.appendChild(divsonimg2);
2014-12-30 09:15 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复