Register • FAQ • Memberlist • Usergroups • Tutorials Point • Log in

| Page 1 of 1

Ajax and callback
Author | Message
--- | ---
Cindy Joined: 16 Jul 2008 Posts: 1 | Ajax and callback I am doing Ajax/JavaScript/Java/JSP coding for a client-server web application. The callback function defined by AJAX was working ok previously on some old LINUX workstation. Recently I moved the development to to a new LINUX system, the callback function didn't get the http response from the servlet where the http request was sent to. As I debug from Netbeans, the servlet did receive the http requst from javascript/Ajax, and it produced the xml response. Also I use Firebug to debug the javascript/AJax code. A breakpoint was set in the beginning of the callback. It seemed that the running didn't reach to the breakpoint (i.e. the callback) after the servlet produce the xml response. I am not sure if there is any setting missing in the new workstation, or in my development environment of the new workstation. Here is part of my javascript/ajax codes,
:
:
// FUNCTION THAT CREATES A NEW AJAX OBJECT TO USE
XMLHttp = function() {
self = this;
if (typeof XMLHttpRequest != 'undefined')
return new XMLHttpRequest();
else if (window.ActiveXObject) {
var avers = ["Microsoft.XmlHttp", "MSXML2.XmlHttp", "MSXML2.XmlHttp.3.0", "MSXML2.XmlHttp.4.0", "MSXML2.XmlHttp.5.0"];
for (var i = avers.length -1; i >= 0; i--) {
try {httpObj = new ActiveXObject(avers[i]);
return httpObj;
} catch(e) {}
}
}
throw new Error('XMLHttp (AJAX) not supported');
}
// AJAX FUNCTION THAT ESTABLISHES A BACKGROUND SESSION WITH SERVER
XMLHttp.prototype.get = function(url) {
self.open('GET', url, true);
self.onreadystatechange = function() { callback(self); }
self.send(null);
}
:
:
function requestA(url)
{
logAjaxRequests = XMLHttp();
logAjaxRequests.open("GET", encodeURI(url), false);
logAjaxRequests.onreadystatechange = function() { callbackA(logAjaxRequests);}
logAjaxRequests.send(null);
}
:
:
function callbackA(rqst) {
var signalAJAXrequest = rqst;
if (signalAJAXrequest.readyState == 4) {
if (signalAJAXrequest.status == 200) {
:
}
}
}
:
Please give me some hint about how this problem can be detected or solved. Thanks.
Thu Jul 17, 2008 12:54 am |

Display posts from previous: |

| Page 1 of 1

You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum

Powered by phpBB © phpBB Group Design by Vjacheslav Trushkin for phpBBStyles.com