What's new

Welcome to the forum 👋, Visitor

To access the forum content and all our services, you must register or log in to the forum. Becoming a member of the forum is completely free.

How come the client side clicking can't cause a function in web server side being called?

Stan Huang

New member
Joined
Nov 25, 2022
Messages
1
Reaction score
0
HTML Coins
0
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:

  1. 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?
  2. What is this call “newAJAXCommand(‘status.xml’, updateStatus, false)” for? where ‘updateStatus’ is a JavaScript function as below.
  3. 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?
JavaScript:
// 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);
}
 

Theme customization system

You can customize some areas of the forum theme from this menu.

  • Wide/Narrow view

    You can control a structure that you can use to use your theme wide or narrow.

    Grid view forum list

    You can control the layout of the forum list in a grid or ordinary listing style structure.

    Picture grid mode

    You can control the structure where you can open/close images in the grid forum list.

    Close sidebar

    You can get rid of the crowded view in the forum by closing the sidebar.

    Fixed sidebar

    You can make it more useful and easier to access by pinning the sidebar.

    Close radius

    You can use the radius at the corners of the blocks according to your taste by closing/opening it.

  • Choose the color combination that reflects your taste
    Background images
    Color gradient backgrounds
Back