SB70LC: web server, AJAX

Discussion to talk about software related topics only.
Post Reply
xianghe
Posts: 6
Joined: Mon Dec 07, 2015 11:29 pm

SB70LC: web server, AJAX

Post by xianghe »

Hello,
I'm working on the NB web server, I know there is network programing guide talk about this, and the key is the callback function mechanism, it's useful to the 'submit' HTML.
But now web page using Javascript AJAX, there is no 'submit' button, can you tell me how to develop the web server?
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: SB70LC: web server, AJAX

Post by rnixon »

I don't think there is anything netburner specific on this. It is web programming. Doing a quick search on "submit form in javascript" I found there is a javascript submit function: http://www.w3schools.com/jsref/met_form_submit.asp. I do not know much about javascript, but my guess would be that it generates a POST just like an HTML form.
xianghe
Posts: 6
Joined: Mon Dec 07, 2015 11:29 pm

Re: SB70LC: web server, AJAX

Post by xianghe »

...I found there is a key function,

Code: Select all

function ajaxSend(reqtype, url, senddata, callback)
{
    var ajaxRequest = null;
    var ajaxCallback;

    ajaxRequest = new XMLHttpRequest();
    
    if(ajaxRequest)
    {
        ajaxRequest.open(reqtype, url, true);

        if(callback)
        {
            ajaxRequest.onload = function()
            {
                var jsonData = JSON.parse(this.responseText);
                ajaxCallback(jsonData);
            }
        }
    }

    if(reqtype === "POST")
    {
       ajaxRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencode");
    }

    if(reqtype === "GET")
    {
       ajaxRequest.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
    }

    ajaxRequest.send(senddata);
There is no 'submit', here is ajaxRequest.send().
ecasey
Posts: 164
Joined: Sat Mar 26, 2011 9:34 pm

Re: SB70LC: web server, AJAX

Post by ecasey »

That Ajax function should send a "get" or "post" request to the url of the SB70. You will have to write a custom get-handler or post-handler to extract the data. Look at the Web examples, there is one called FlashForm that might be helpful.
Post Reply