当前位置: 动力学知识库 > 问答 > 编程问答 >

jquery - responseXML.xml is not an object

问题描述:

I'm am trying to determine a users role using the SP Services library (http://spservices.codeplex.com/), however I am getting responseXML.xml is not an object error.

SPServices + JQuery are both referenced correctly.

Code:

<script type="text/javascript">

$(document).ready(function() {

$().SPServices({

operation: "GetRolesAndPermissionsForCurrentUser",

async: false,

completefunc: function(xData, Status) {

alert(xData.responseXML.xml);

var userPerm = $(xData.responseXML).find(" [nodeName=Permissions]").attr("Value");

alert("userPerm = " + userPerm);

}

});

});

</script>

网友答案:

Why are trying to use that property of responseXML? If you want access to the raw XML markup, then use the responseText property of xData instead.

I assume that your real goal with the function above (to get the permission) is actually working, correct?

responseXML is a XML Document object that may have different structure depending on browser.

网友答案:

Are you using jQuery 1.9.1? I that case it's an bug. https://bugs.jquery.com/ticket/13388

Ajax response object property responseXML will be undefined. While responseText is containing the raw XML response. Reference a newer jQuery will populate responseXML correctly.

分享给朋友:
您可能感兴趣的文章:
随机阅读: