tags:

views:

4

answers:

0

I am executing an ajax request using dojo, I have a call back function which has the response object. when i put an alert statement on the response object , it shows different in Firefox and safari. In Firefox it shows as a XMLDocument where as in Safari it shows as a Document. Due to this I am facing some problems in extracting the data out of XML. On putting the statements like response.getElementsByTagName("opensearch:totalResults") Firefox returns HTMLCollection object where as Safari return NodeList object and even when i check the length of these objects it shows different , for Firefox it shows 1 where as for safari it shows 0.Due to this i am not able to extract the data from the xml.

Here's the code snippet

BELOW is the function that makes the AJAX call :

function getPeople(){ 
 hostName = document.wizardForm.hostName.value; 
 nameSearch = document.wizardForm.inviteeName.value;
 startIndex = 1;
 var searchUrl = "https://"+hostName+"/profiles/atom/search.do?name="+nameSearch;
 page = '1';
 var d = dojo.xhrGet({
   url:searchUrl,
   load:afterResponse,
   handleAs:"xml",
   error:function(response, ioArgs){
    console.log("error", response, ioArgs);      
   }
  });  
 }

CALLBACK FUNCTION :

    function afterResponse(response){

    alert("search result ::"+response);         
    var totalCollectionNode = response.getElementsByTagName("opensearch:totalResults");    
    alert("lenght ::"+totalCollectionNode.length);      

    totalRecords = response.getElementsByTagName("opensearch:totalResults")[0].childNodes[0].nodeValue;    

    itemPerPage = response.getElementsByTagName("opensearch:itemsPerPage")[0].childNodes[0].nodeValue;


    var totalPages = Math.round(eval(totalRecords)/eval(itemPerPage));
   }