Hi,
I am using AJAX JSON over HTTP to send using CGI. It is working. Does Keil web server CGX supports JSON RPC.
Currently I have to Post JSON using CGX using
$.ajax({ type: "POST", url: "xmlHttp.cgx", data: post_data, contentType: "text/xml", datatype : "text", success: function(data) {
}, error: function (xhr, ajaxOptions, thrownError) {
} });
contentType is xml. If I set JSON/application then I do not get cgi_process_data call.
I notice that you have the function
void cgi_process_data ( U8 code, /* Type of data in received data buffer. */ U8* dat, /* Pointer to the data string from the POST method. */ U16 len ); /* Number of bytes in the data string. */
code = 0 means a POST with form data operation. code = 4 means a POST with some other data.
So if code is 4, then the user has to call
U8 *http_get_content_type (void);
to check for example if the received data was 'application/json' or whatever the embedded device might want to process.
Can the web server only handle one single page request at a time - or how is the global state of http_get_content_type() handled? How long is it valid? Until cgi_process_data() returns?
Another thing - why does the Keil HTTP documentation specifically discuss Silverlight? Silverlight is one in a million different sources of M2M-communicated data. I feel the manual would do better mentioning lifetime of data than mentioning a MS-specific tool.
HTTP server can handle several sessions simultaneously and can correctly process multiple POST requests at the same time.
The function http_get_content_type() must be called from cgi_process_data() callback. The session instance is internally handled in the library.