lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Best way to return JSON data for AJAX


From: Marco Lazzaroni
Subject: Re: [lwip-users] Best way to return JSON data for AJAX
Date: Wed, 15 Apr 2020 18:50:28 +0200

Hi,
  If I understand correctly, I'm doing something similar here.

I have created a json file as below:
{
    "ssl_ok_count": "<!--#SslOkCount-->",
    "ssl_err_count": "<!--#SslErrCount-->",
    "ssl_log": "<!--#SslLog-->"
}

Then in the _javascript_ you have to do something like this:
/* this is from the XMLHttpRequest */ 
obj = JSON.parse(stripAwayComments(this.responseText));
document.getElementById("id_ssl_ok_count").innerHTML = obj.ssl_ok_count;
document.getElementById("id_ssl_err_count").innerHTML = obj.ssl_err_count;
document.getElementById("id_ssl_log").innerHTML = obj.ssl_log;

This is the related function, called above
function stripAwayComments(str) {
return str.replace(/<\!--.*?-->/g, "");
}

This is because I was not aware of LWIP_HTTPD_SSI_INCLUDE_TAG, see the related comments in httpd.h and httpd_opts.h.
With LWIP_HTTPD_SSI_INCLUDE_TAG set at 0, you can change the line above to 
obj = JSON.parse(this.responseText);

I think that I'm facing the same problem you have because my "char log_memory[10240]" array should be appended to my SslLog tag. So, I don't think that setting LWIP_HTTPD_MAX_TAG_INSERT_LEN to 10240 is the correct approach :-)
LWIP_HTTPD_SSI_MULTIPART has been written for this need, now I just have to understand how to implement the suggestion you linked (https://lists.gnu.org/archive/html/lwip-users/2017-11/msg00151.html).

Hope this helps 
Marco


Il giorno mer 15 apr 2020 alle ore 18:17 Dave Nadler <address@hidden> ha scritto:

Hi All - I'm looking for guidance on good ways to return JSON data for use in a web page via AJAX.
I found a couple of threads discussing using SSI for this but I'm unclear the overall approach.
For this application I don't need to worry about session IDs - just need to return some JSON
data, in multiple chunks to avoid chewing up enormous memory in prep.
Thanks in advance for any guidance (or even better an example!),
Best Regards, Dave

References:
https://lists.gnu.org/archive/html/lwip-users/2017-11/msg00137.html
http://lwip.100.n7.nabble.com/LWIP-HTTPD-SSI-MULTIPART-and-concurrent-HTTP-requests-td31266.html


-- 
Dave Nadler, USA East Coast voice (978) 263-0097, address@hidden, Skype 
 Dave.Nadler1
_______________________________________________
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]