We are currently experiencing intermittent login issues on Community.  The team is actively working on a fix.

var answer = response.responseXML.documentElement.getAttribute("answer");

Bilal Usuf
Kilo Contributor

hi what is the work of "answer"....and what is get Attribute doing here pleae any one can explain me the complete line var answer = response.responseXML.documentElement.getAttribute("answer");

1 ACCEPTED SOLUTION

varunagarwal
ServiceNow Employee
ServiceNow Employee

var answer =response.responseXML.documentElement.getAttribute("answer");



Let us assume we have a function in Script Include :



demofunction: function () {


        var element = this.getParameter('sysparm_parameter');


return 'Hi, This is bind with answer atrribute';


}



Now in client script   -


function myCallBack(response) {


        var answer = response.responseXML.documentElement.getAttribute("answer");


alert(answer); // Output   "Hi, This is bind with answer atrribute"


}



Here "response" is an XML document which contains an attribute "answer" and the value returned from the demofunction binded with the answer attribute.


So response.responseXML.documentElement.getAttribute("answer") gives us the value returned from the script include function.



Award Correct Answer if my Solution Works, Mark helpful if it helps...


View solution in original post

5 REPLIES 5

varunagarwal
ServiceNow Employee
ServiceNow Employee

var answer =response.responseXML.documentElement.getAttribute("answer");



Let us assume we have a function in Script Include :



demofunction: function () {


        var element = this.getParameter('sysparm_parameter');


return 'Hi, This is bind with answer atrribute';


}



Now in client script   -


function myCallBack(response) {


        var answer = response.responseXML.documentElement.getAttribute("answer");


alert(answer); // Output   "Hi, This is bind with answer atrribute"


}



Here "response" is an XML document which contains an attribute "answer" and the value returned from the demofunction binded with the answer attribute.


So response.responseXML.documentElement.getAttribute("answer") gives us the value returned from the script include function.



Award Correct Answer if my Solution Works, Mark helpful if it helps...