This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

JSON over HTTP

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.

Parents
  • 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. */

    Content-Type: application/json is not working.

    I can cheat Keil by either not specifying Content-Type at all then I get
    code =0
    or specify Content-type : text/xml then I get code =4

    In both cases it is alight which is I can post/send json data and then I can parse json data but It is not strictly Content-Type: application/json which I am looking.

    Only issue is post. response of post is good I can specify "application/json" by override for response.

    const char *netCGX_ContentType (void)
    { return ("application/json");
    }

    Any thoughts how we can fix it or this is limitation of Keil.

    Another question.
    I cannot find any keil HTTP functions to get request URL. I may like to do RestFul style ajax calls in this case I need to differentiate which method is requested by parsing URL.

Reply
  • 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. */

    Content-Type: application/json is not working.

    I can cheat Keil by either not specifying Content-Type at all then I get
    code =0
    or specify Content-type : text/xml then I get code =4

    In both cases it is alight which is I can post/send json data and then I can parse json data but It is not strictly Content-Type: application/json which I am looking.

    Only issue is post. response of post is good I can specify "application/json" by override for response.

    const char *netCGX_ContentType (void)
    { return ("application/json");
    }

    Any thoughts how we can fix it or this is limitation of Keil.

    Another question.
    I cannot find any keil HTTP functions to get request URL. I may like to do RestFul style ajax calls in this case I need to differentiate which method is requested by parsing URL.

Children