Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Below are code snippets. I've got two questions for the two calls inside function
rescanNetwork
:
JavaScript
<pre>    newAJAXCommand('scan.cgi?scan=1');

and
JavaScript
<pre>    setTimeout("newAJAXCommand('status.xml', updateStatus, false)", 50);


For the first call, the parameter (
Quote:
'scan.cgi?scan=1'
)
but the content of scan.cgi is "
Quote:
Success! ~scan~
". In my understanding, scan.cgi is a CGI script, how come "Success! ~scan~" doesn't look like a script program? What language is it?
For the second call,
Quote:
"newAJAXCommand('status.xml', updateStatus, false)"

, status.xml should be a CGI script too, but can a XML file be a script program?

JavaScript
<pre>
// 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);
}

JavaScript
<pre>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);
}


What I have tried:

I studied relative knowledge inside this post, but still unable to figure out my question.
Posted
Comments
Graeme_Grant 31-Oct-22 2:28am    
newAJAXCommand is client-side code (from the web browser) making a request with a remote server. Do you have access to the server's code?
Stan Huang 22-Nov-22 4:55am    
Yes, I have access to the server, which is an embedded system.
Member 15627495 31-Oct-22 3:33am    
hello,

as a reminder :
scan.cgi is a file ( the target of the ajax call you did ), you know ["name.extension"].
cgi are ancestors of lot of php resources, a solution to call Apache server.

if you have an answer by the call "scan=1", it's because the cgi module is 'alive' in your server setup.
perl was a server sided scripting language before php growth.
Stan Huang 22-Nov-22 4:58am    
So, I still don't understand what 'scan.cgi?scan=1' means at statement "newAJAXCommand('scan.cgi?scan=1');". Could you explain them?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900