/*
-** $Id: pz2.js,v 1.23 2007-06-01 08:06:17 jakub Exp $
+** $Id: pz2.js,v 1.32 2007-06-04 12:49:21 jakub Exp $
** pz2.js - pazpar2's javascript client library.
*/
}
else {
var nodeName = hits[i].childNodes[j].nodeName;
- var nodeText = hits[i].childNodes[j].firstChild.nodeValue;
+ var nodeText = 'ERROR'
+ if ( hits[i].childNodes[j].firstChild )
+ nodeText = hits[i].childNodes[j].firstChild.nodeValue;
show.hits[i][nodeName] = nodeText;
}
}
if ( recordNode = data.getElementsByTagName("record")[0] ) {
// if stylesheet was fetched do not parse the response
if ( __myself.xslDoc ) {
+ record['recid'] = recordNode.getElementsByTagName("recid")[0].firstChild.nodeValue;
record['xmlDoc'] = data;
record['xslDoc'] = __myself.xslDoc;
} else {
//for each term in the list
for (j = 0; j < terms.length; j++) {
var term = {
- "name": terms[j].getElementsByTagName("name")[0].childNodes[0].nodeValue,
- "freq": terms[j].getElementsByTagName("frequency")[0].childNodes[0].nodeValue
+ "name": (terms[j].getElementsByTagName("name")[0].childNodes.length
+ ? terms[j].getElementsByTagName("name")[0].childNodes[0].nodeValue
+ : 'ERROR'),
+ "freq": terms[j].getElementsByTagName("frequency")[0].childNodes[0].nodeValue || 'ERROR'
};
var termIdNode = terms[j].getElementsByTagName("id");
var paramArr = new Array();
for ( var key in params ) {
- paramArr.push(key + '=' + params[key] );
+ paramArr.push(key + '=' + encodeURI(params[key]) );
}
if ( paramArr.length )
var context = this;
this.request.open( 'GET', getUrl, true );
- this.request.setRequestHeader('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7');
+ this.request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
+ //this.request.setRequestHeader('Accept-Charset', 'UTF-8');
this.request.onreadystatechange = function () {
context._handleResponse();
}