Why can't the CGI work as expected?

User 3131431 Photo


Guest
1 post

Below are my AJAX code snippet.
In rescanNetwork(), there are two calls of newAJAXCommand(). The first one “newAJAXCommand(‘scan.cgi?scan=1’);” The second one is “setTimeout(“newAJAXCommand(‘status.xml’, updateStatus, false)”, 50)”
The content of scan.cgi is kind of “Success! scan”. My questions are:

Per my understanding, scan.cgi must be a CGI script written in Perl, Python, or another scripting language. “Success! scan” doesn’t look like a script of any language. How come? What does it mean?
What is this call “newAJAXCommand(‘status.xml’, updateStatus, false)” for? where ‘updateStatus’ is a JavaScript function as below.
In “newAJAXCommand”, once “newAjax.ajaxReq.send(data);” is executed, the server side associated function must be called, but I found no function was called. How can I find the missing place?

// Initiates a new AJAX command
// url: the url to access
// container: the document ID to fill, or a function to call with response XML (optional)
// repeat: true to repeat this call indefinitely (optional)
// data: an URL encoded string to be submitted as POST data (optional)
function newAJAXCommand(url, container, repeat, data)
{
// Set up our object
var newAjax = new Object();
var theTimer = new Date();
newAjax.url = url;
newAjax.container = container;
newAjax.repeat = repeat;
newAjax.ajaxReq = null;

// Create and send the request
if (window.XMLHttpRequest) {
newAjax.ajaxReq = new XMLHttpRequest();
newAjax.ajaxReq.open((data==null)?"GET":"POST", newAjax.url, true);
newAjax.ajaxReq.send(data);
// If we're using IE6 style (maybe 5.5 compatible too)
} else if (window.ActiveXObject) {
newAjax.ajaxReq = new ActiveXObject("Microsoft.XMLHTTP");
if (newAjax.ajaxReq) {
newAjax.ajaxReq.open((data==null)?"GET":"POST", newAjax.url, true);
newAjax.ajaxReq.send(data);
}
}

newAjax.lastCalled = theTimer.getTime();

// Store in our array
ajaxList.push(newAjax);
}

.......
function updateStatus(xmlData)
{
......
}
.....

function rescanNetwork()
{
scanDots = 0;
printButtonName();
document.getElementById("rescan").disabled = true;

// Generate a request to hardware to issue a rescan
newAJAXCommand('scan.cgi?scan=1');

// Delete old table, replace with new table after scan is finished
deleteScanTable();

currBss = 0; // Reset the current bss pointer

setTimeout("newAJAXCommand('status.xml', updateStatus, false)", 50);
}
User 379556 Photo


Registered User
1,558 posts

I see that this question is also at https://www.sitepoint.com/community/t/s … des/402084 where an answer was provided but not followed up apart from mention about that forum's time limits.

This forum is provided by CoffeeCup software and relates primarily to that. It's just possible that someone will provide an answer here, but I suspect it's unlikely. I suggest that the matter continue to be pursued at the link above or some other such more general coding forum.

Frank

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.