lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] httpd: how to implement AJAX


From: Noam Weissman
Subject: Re: [lwip-users] httpd: how to implement AJAX
Date: Mon, 13 Nov 2017 13:34:25 +0000

Hi,

I am using the following technic for AJAX.

Create an empty file named ajax.shtml or ajax.html and add it to your file list.

Inside the file you only write one tag without anything else. For example 
<!--#AjaxCall-->

Do not add  CR or LF just the tag !!.

Now when you issue an AJAX call the WEB server opens the file, reads it and 
send its data.
Because the file has only the tag it will parse it, call your handler for that 
tag and send back 
To the browser just your data !!

If you use Juery it will look something like this... actually a function used 
as an event handler in 
my own code:

function resetIO()
      {
        //Remove the dialog
        returnToPage();
        
        $.ajax({
          url: "ajax.shtml",
          dataType : "text",
          type : "GET",
          cache : false,
          data : ({
            ssid: ssid,
            a: 'opReset',
            type: 2
          }),
          error : function()
          {
            showMessage("Network Error: Sorry, there was a problem connecting 
to the server.");
          },    
          success : function(result) 
          {
            window.location.href = document.location;
          }
        });
      }

In the above data you have the a:  variable,  this is your AJAX action !. 

In your own SSI/CGI code you have a table with tags + callbacks... one of the 
callback function
Is your AJAX handler. Inside it you create an if <> else layout and handle the 
different actions.

The HTTP server will read your ajax.shtml file and because it has nothing BUT 
your tag it will 
only send back the dynamic data you process in your ajax handling function.


Hope that helped,
Noam.



-----Original Message-----
From: lwip-users [mailto:address@hidden On Behalf Of Giuseppe Modugno
Sent: Monday, November 13, 2017 12:43 PM
To: address@hidden
Subject: [lwip-users] httpd: how to implement AJAX

I'm trying to create a website with AJAX technology: the client polls, at 
regular intervals, the server with GET requests of file /status.json. 
The response is dynamic.

I could use only LWIP_HTTPD_CUSTOM_FILES and create the file at runtime in 
fs_open_custom(). It works, but I can't decode the query string, because it 
isn't passed to fs_open_custom() callback.

So I thought to use LWIP_HTTPD_CGI_SSI instead of LWIP_HTTPD_CUSTOM_FILES, but 
I have some difficulties to understand how it works.
First of all, the file /status.json must be present in the filesystem
(fs_open() must return ERR_OK), otherwise httpd_cgi_handler() isn't called at 
all.
However I can't return any data in httpd_cgi_handler().

Any help?


_______________________________________________
lwip-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users



reply via email to

[Prev in Thread] Current Thread [Next in Thread]