Question CGI / FastCGI and AJAX with C/C++

Jul 27, 2020
24,268
16,917
146
I need to understand the flow of AJAX in an application that is using CGI with C/C++. I can't wrap my head around what values are getting passed via CGI to the executable when AJAX is used. Once I understand this, I would like to upgrade to FastCGI as it is faster and more memory efficient. I would really appreciate if someone would volunteer to let me pick their brain. Thanks!
 
Jul 27, 2020
24,268
16,917
146
I already have connectivity via CGI using a CGI library. I suppose CGI could be made secure by using safe string handling functions/libraries? Also, I don't intend to use CGI over the internet but rather over an intranet. What I can't seem to figure out is how to successfully pass data using AJAX between the page and the C/C++ executable. Sample code showing such an interaction would be awesome. Thanks.
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,577
4,492
75
Oh. AJAX. AJAX is just JavaScript internally GETting (or POSTing to) a URL. The data returned need not look like a web page; JSON is a common format, but far from the only one. Security (of who can access that URL) can be handled by standard methods, or by you. Cookies or tokens generated after a login are common methods. Cookies are read by the HTTP_COOKIE environment variable, or, hopefully, your C/C++ CGI library. Regarding the security I mentioned earlier, if you have a C/C++ CGI library, it's probably sanitizing most of your data well enough.

You act like you want AJAX to communicate with a C/C++ executable that might already be running in the background. Is that the case? CGI starts brief, little, inherently-stateless processes. If you want to communicate with another process, you need to set up inter-process communication (IPC) yourself. A very basic method would be simple files that are watched for. What's available depends on your server's OS.
 
Jul 27, 2020
24,268
16,917
146
You act like you want AJAX to communicate with a C/C++ executable that might already be running in the background. Is that the case?
Only FastCGI can keep running in the background. That's my next step after I can do AJAX. I mainly want to do AJAX so it can update the page without refreshing the whole page. However, all around the web, I can only find mostly PHP AJAX code.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126
Note: I'm NOT a programmer. Maybe just better at searching stuff, I think.

==

Googled results:

Ajax: A New Approach to Web Applications

Ajax Frameworks


FastCGI arg list

Do you really have to use CGI/FastCGI with C?
javascript - JQuery AJAX + C CGI - Stack Overflow

Websockets

-- Full duplex messaging between web browsers and servers

==
No Ajax framework.

==

==
Asynchronous JavaScript Tutorial

==
Web programming with c++
 
Last edited: