XMLHttpRequest in IE7 ...?
Posted by Fredrik Paulsson on 25.Jan.11 at 07:56 AM using a Web browser Category : Application development Release: All Releases Platform: All Platforms
Use the following code to retrieve values from a view column, works perfectly with IE8, Firefox, Chrome and Safari. However, retrieved nothing if I use IE7?
Have read around in various threads and forums and senses that it has to do with the XMLHttpRequest in IE7 ... Someone who has an eye on this and can guide me on track. Do not really know where to begin.
dojo.provide("CHANNEL.util");
dojo.declare("CHANNEL.util", null, {
xhr: function(/*Object*/props){
var parms = dojo._toArray(arguments, 1);
if(props.responseHandler){
if(dojo.isString(props.responseHandler)){
props.responseHandler = dojo.eval(props.responseHandler);
}
}else{
props.sync = true;
}
var xhrArgs = {
url: props.url,
timeout: props.timeout || 5000,
preventCache: props.preventCache || true,
handleAs: props.handleAs || "json",
sync: props.sync || false,
headers: props.headers,
content: props.content,
form: props.form,
load: dojo.hitch(this, function(response, ioArgs){
if(props.responseHandler){
parms.unshift(response);
dojo.hitch(this, props.responseHandler).apply(null,parms);
}
return response;
}),
error: function(response, ioArgs){
//ERROR
console.error(response, ioArgs);
return response;
}
};
if(props.postData){
xhrArgs.postData = props.postData;
}
var xhrFunc = props.post ? dojo.xhrPost : dojo.xhrGet;
var oXHR = xhrFunc(xhrArgs);
if(props.sync){
return oXHR.results[0];
}
},
returnColumnValue: function(/*Object*/obj){
for(var a in obj) {
switch(a){
case "text":
case "number":
case "datetime":
if(dojo.isArray(obj[a])){
var items = [];
for(var i=0; i<obj[a].length; i++){
switch(a){
case "datetime":
items.push(this.returnDateTime(obj[a][i][0]));
break;
default:
items.push(obj[a][i][0]);
break;
}
}
return items;
}else{
switch(a){
case "datetime":
return this.returnDateTime(obj[a][0]);
break;
default:
return obj[a][0];
break;
}
}
break;
case "textlist":
case "numberlist":
case "datetimelist":
return this.returnColumnValue(obj[a]);
break;
default:
break;
}
}
return "";
},
});
dojo.provide("CHANNEL.programForm");
dojo.require("CHANNEL.util");
dojo.declare("CHANNEL.arendeForm", [CHANNEL.util], {
constructor: function(/* Object */args){
dojo.mixin(this, args);
this.getUsernames();
this.getPLValue();
},
//####################################################
// PROGRAM with JSON - START
//####################################################
getPLValue: function(){
var oParms = {
url : '../../../Main.nsf/program?ReadViewEntries&count=1894&OutputFormat=JSON',
responseHandler : this.populateTagKeywordFields
}
this.xhr(oParms);
},
populateTagKeywordFields: function(oJSON){
if(oJSON["@toplevelentries"] && oJSON["@toplevelentries"] > 0){
try{
var aProgram = new Array();
var countX = oJSON["@toplevelentries"];
var viewentries = oJSON.viewentry;
for (i = 0 ; i < countX ; i++){
var edata = viewentries[i].entrydata;
aProgram.push(this.returnColumnValue(edata[0]));
}
this.populateTagSelectOptions("c_Program", aProgram);
}catch(e){
console.error(e);
}
}
},
populateTagSelectOptions: function(sFieldName, aValues){
var iIndex, oField;
try{
if(typeof(aValues) == "string"){
aValues = aValues.split();
}
oField = dojo.byId(sFieldName);
for(var i = 0; i < aValues.length; i++){
if(oField){
iIndex = oField.options.length;
oField.options[iIndex] = new Option(aValues[i], aValues[i]);
try{
if(eval(sFieldName) == aValues[i]){
oField.options[iIndex].selected = true;
}
}catch(e){}
}
}
}catch(e){
console.error(e);
}
},
Resources
Lotus Support
Wikis
Lotus Forums