本文介绍了将microsoft.XMLDOM转换为Jquery,它使用xml数据类型。下面的函数需要转换为JQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 function doLoadGridPage(iPage){ try { oXML = new ActiveXObject( microsoft.XMLDOM); oXML。 async = false ; oXML.load( processXMLData.asp?action = loadGridPage& pn = + iPage ); if (oXML.readyState == 4 ) { var buttons = oXML.selectNodes( / ROOT / vw_admin-网格按钮); var x,y,z; // 清除所有按钮...... for (y = 1 ; y < = colMax; y ++) { for (x = 1 ; x < = rowMax; x ++){ var ref1 = row + x + col + y ; document.getElementById(ref1).style.color = ' black' ; document.getElementById(ref1).style.background = ' silver'; document.getElementById(ref1).style.fontStyle = normal; document.getElementById(ref1).style.fontWeight = normal; document.getElementById(ref1).style.textDecoration = none; document.getElementById(ref1).pageNumber = iPage; document.getElementById(ref1).rowNumber = x; document.getElementById(ref1).columnNumber = y; document.getElementById(ref1).buttonTypeId = null ; document.getElementById(ref1).buttonInstanceId = null ; document.getElementById(ref1).buttonInstanceCaption = null ; document.getElementById(ref1).caption = null ; document.getElementById(ref1).buttonInstanceStyleId = null ; document.getElementById(ref1).restricted = false ; document.getElementById(ref1).buttonStyleId = null ; document.getElementById(ref1).telephoneNumber = null ; document.getElementById(ref1).pageJumpDestination = null ; document.getElementById(ref1).pageId = null ; document.getElementById(' div' + ref1).innerHTML = & nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& nbsp;& NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP;&安培; NBSP; ; } } // 填充返回的按钮... var pageHasRestrictedButtons = false ; for (z = 0 ; z < ; buttons.length; z ++){ if (buttons [z] .childNodes){ var buttonInstanceId = buttons [z] .selectSingleNode( ./ ID)文本; var buttonTypeId = buttons [z] .selectSingleNode( ./ ButtonTypeId)文本; var buttonTypeName = buttons [z] .selectSingleNode( ./类型名)文本。 var buttonStyleId = buttons [z] .selectSingleNode( ./ StyleId)文本。 var buttonInstanceStyleId = buttons [z] .selectSingleNode( ./ ButtonInstanceStyleId)文本; var idleforecolour = buttons [z] .selectSingleNode( ./ IdleForeColour)文本。 var idlebackcolour = buttons [z] .selectSingleNode( ./ IdleBackColour)文本。 var buttonInstanceCaption = buttons [z] .selectSingleNode( ./ ButtonInstanceCaption)文本。 var caption = buttons [z] .selectSingleNode( ./标题)文本。 var pageId = buttons [z] .selectSingleNode( ./ PageEntryId)文本。 var row = buttons [z] .selectSingleNode( ./行); var col = buttons [z] .selectSingleNode( ./山口); var telephonenumber; var pagejumpdestination; var splitCaption = caption.replace( \\\\\\ n, < BR />); 尝试 { telephonenumber = buttons [z] .selectSingleNode( ./ telephonenumber); } catch (e){ // 未找到节点 } 尝试 { pagejumpdestination = buttons [z] .selectSingleNode( ./ PageJumpDestination); } catch (e){ // 未找到节点 } var ref = row + row.text + col + col.text; var hasPermission = checkButtonTypePermission(buttonTypeName); 尝试 { if (!hasPermission) { pageHasRestrictedButtons = true ; } document.getElementById(' div' + ref )。innerHTML = splitCaption + < BR /> ; +(checkButtonTypePermission(buttonTypeName)== true ? : (受限制)); } catch (e){ // 找不到单元格,它可能是超出我们当前网格大小的按钮 continue ; } if (buttonInstanceCaption!= caption || buttonInstanceStyleId!= buttonStyleId){ document .getElementById( ref )。style.fontStyle = italic ; document.getElementById( ref )。style.fontWeight = 900 ; document.getElementById( ref )。style.textDecoration = 下划线; } document.getElementById( ref )。restricted =!hasPermission; document.getElementById( ref )。pageId = pageId; document.getElementById( ref )。buttonTypeId = buttonTypeId; document.getElementById( ref )。buttonTypeName = buttonTypeName; document.getElementById( ref )。buttonInstanceCaption = buttonInstanceCaption; document.getElementById( ref )。caption = caption; document.getElementById( ref )。buttonInstanceId = buttonInstanceId; document.getElementById( ref )。buttonInstanceStyleId = buttonInstanceStyleId; document.getElementById( ref )。buttonStyleId = buttonStyleId; document.getElementById( ref )。style.color = idleforecolour; document.getElementById( ref )。style.background = idlebackcolour; if (telephonenumber){ document.getElementById( ref ).telephoneNumber = telephonenumber.text; } if (pagejumpdestination){ document.getElementById( ref )。pageJumpDestination = pagejumpdestination.text; } } } document.getElementById( deletePageBtn )。disabled = pageHasRestrictedButtons; document.getElementById( copyPage)。disabled = pageHasRestrictedButtons; } } catch (e){ return ; } 删除oXML; } 解决方案 .ajax({ 类型:POST, url:processXMLData.asp?action = loadGridPage&pn =+ iPage, dataType:xml, cache:false, async:false, 成功:function(xml) (xml ).find(''ROOT vw_admin-grid-buttons'')。each(function() { }); }, 错误:函数(ts){ var start = ts.responseText.search(< title>)+ 7; var end = ts.responseText.search(< / title>); if(start> 0 && end> 0) alert(ts.responseText.substring(start,end)); else alert(ts); } }); function doLoadGridPage(iPage) { try { oXML = new ActiveXObject("microsoft.XMLDOM"); oXML.async = false; oXML.load("processXMLData.asp?action=loadGridPage&pn=" + iPage); if (oXML.readyState == 4) { var buttons = oXML.selectNodes("/ROOT/vw_admin-grid-buttons"); var x, y, z; // Clear all buttons... for (y = 1; y <= colMax; y++) { for (x = 1; x <= rowMax; x++) { var ref1 = "row" + x + "col" + y; document.getElementById(ref1).style.color = 'black'; document.getElementById(ref1).style.background = 'silver'; document.getElementById(ref1).style.fontStyle = "normal"; document.getElementById(ref1).style.fontWeight = "normal"; document.getElementById(ref1).style.textDecoration = "none"; document.getElementById(ref1).pageNumber = iPage; document.getElementById(ref1).rowNumber = x; document.getElementById(ref1).columnNumber = y; document.getElementById(ref1).buttonTypeId = null; document.getElementById(ref1).buttonInstanceId = null; document.getElementById(ref1).buttonInstanceCaption = null; document.getElementById(ref1).caption = null; document.getElementById(ref1).buttonInstanceStyleId = null; document.getElementById(ref1).restricted = false; document.getElementById(ref1).buttonStyleId = null; document.getElementById(ref1).telephoneNumber = null; document.getElementById(ref1).pageJumpDestination = null; document.getElementById(ref1).pageId = null; document.getElementById('div' + ref1).innerHTML = " "; } } // Populate the returned buttons... var pageHasRestrictedButtons = false; for (z = 0; z < buttons.length; z++) { if (buttons[z].childNodes) { var buttonInstanceId = buttons[z].selectSingleNode("./ID").text; var buttonTypeId = buttons[z].selectSingleNode("./ButtonTypeId").text; var buttonTypeName = buttons[z].selectSingleNode("./TypeName").text; var buttonStyleId = buttons[z].selectSingleNode("./StyleId").text; var buttonInstanceStyleId = buttons[z].selectSingleNode("./ButtonInstanceStyleId").text; var idleforecolour = buttons[z].selectSingleNode("./IdleForeColour").text; var idlebackcolour = buttons[z].selectSingleNode("./IdleBackColour").text; var buttonInstanceCaption = buttons[z].selectSingleNode("./ButtonInstanceCaption").text; var caption = buttons[z].selectSingleNode("./Caption").text; var pageId = buttons[z].selectSingleNode("./PageEntryId").text; var row = buttons[z].selectSingleNode("./Row"); var col = buttons[z].selectSingleNode("./Col"); var telephonenumber; var pagejumpdestination; var splitCaption = caption.replace("\\r\\n", "<BR />"); try { telephonenumber = buttons[z].selectSingleNode("./telephonenumber"); } catch (e) { // Node not found } try { pagejumpdestination = buttons[z].selectSingleNode("./PageJumpDestination"); } catch (e) { // Node not found } var ref = "row" + row.text + "col" + col.text; var hasPermission = checkButtonTypePermission(buttonTypeName); try { if (!hasPermission) { pageHasRestrictedButtons = true; } document.getElementById('div' + ref).innerHTML = splitCaption + "<BR />" + (checkButtonTypePermission(buttonTypeName) == true ? "" : "(restricted)"); } catch (e) { // cell not found, it is likely to be a button defined beyond our current grid size continue; } if (buttonInstanceCaption != caption || buttonInstanceStyleId != buttonStyleId) { document.getElementById(ref).style.fontStyle = "italic"; document.getElementById(ref).style.fontWeight = 900; document.getElementById(ref).style.textDecoration = "underline"; } document.getElementById(ref).restricted = !hasPermission; document.getElementById(ref).pageId = pageId; document.getElementById(ref).buttonTypeId = buttonTypeId; document.getElementById(ref).buttonTypeName = buttonTypeName; document.getElementById(ref).buttonInstanceCaption = buttonInstanceCaption; document.getElementById(ref).caption = caption; document.getElementById(ref).buttonInstanceId = buttonInstanceId; document.getElementById(ref).buttonInstanceStyleId = buttonInstanceStyleId; document.getElementById(ref).buttonStyleId = buttonStyleId; document.getElementById(ref).style.color = idleforecolour; document.getElementById(ref).style.background = idlebackcolour; if (telephonenumber) { document.getElementById(ref).telephoneNumber = telephonenumber.text; } if (pagejumpdestination) { document.getElementById(ref).pageJumpDestination = pagejumpdestination.text; } } } document.getElementById("deletePageBtn").disabled = pageHasRestrictedButtons; document.getElementById("copyPage").disabled = pageHasRestrictedButtons; } } catch (e) { return; } delete oXML; } 解决方案 .ajax({ type: "POST", url: "processXMLData.asp?action=loadGridPage&pn=" + iPage, dataType: "xml", cache: false, async: false, success: function(xml) (xml).find(''ROOT vw_admin-grid-buttons'').each(function () { }); }, error: function(ts) { var start = ts.responseText.search("<title>") + 7; var end = ts.responseText.search("</title>"); if (start > 0 && end > 0) alert(ts.responseText.substring(start, end)); else alert(ts); } }); 这篇关于将microsoft.XMLDOM转换为Jquery,它使用xml数据类型。下面的函数需要转换为JQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 11-01 16:03