In using Dojo, I tried to return an XML String from the server side, and parsed it in the javascript. This is the code portion for making the AJAX call:
retrieveUserDetail = function(id) {
// Use dojo.io.bind() for remoting
dojo.io.bind({
// URL - destination you want to send your request
url: “validate?id=” + escape(data.Id),// Callback function that will be invoked asynchronously
load: function(type, data, evt){ processRetrieval(data);},// Error handler function that will be invoked in case of an error
error: function(type, error){ alert(”error”); },// Backward and forward button handling
backButton: function() { alert(”back button pressed”); },
forwardButton: function() { alert(”forward button pressed”);},// Type of data you want to receive
mimetype: “text/xml”
});
}processRetrieval = function(data) {
var message = data.getElementsByTagName(”loginName”)[0].childNodes[0].nodeValue;
var userId = dojo.byId(”fUserId”);
userId.value = message;
userId.disabled = “true”;
}
As specified, I used mimetype in the dojo.io.bind() function. This works in Firefox perfectly, but in Internet Explorer, it does not work. IE will recognize the responding result as plain text. As a result, you have to explicitly declared in the server side telling that the result is in XML format. For me, I am developing Java Web Application, so I used this in the servlet:
response.setContentType(”text/xml”);
By doing this, IE will recognize the result as XML document.
Reference:
http://dojotoolkit.org/pipermail/dojo-checkins/2007-January/015183.html









No comments
Comments feed for this article
Trackback link
http://blog.planner4u.org/blog/2007/01/31/tricky-things-on-using-dojo-with-internet-explorer/trackback/