Note that there are some explanatory texts on larger screens.

plurals
  1. POServer side processing for dojo ajax
    primarykey
    data
    text
    <p>I would like to post client side JSON data to the server where it will be read by a cgi-bin perl script. Been searching for examples on how to read the data on the server side but found nothing. I am using dojo version 1.8.1....</p> <p>I can see that the request comes in on the server side to the cgi script but searching input values turns up no JSON data.</p> <p>On the server side, I can see the 'cmd' parm passed from url property and I also see '1' with no data. I have download and installed JSON.pm on the server side but can't find the JSON data from the client after the POST.</p> <p>How does a server side perl script read the JSON data posted by the client??</p> <p>Thx!!! </p> <pre><code>var xhrArgs = { url: "/cgi-bin/DataExport.cgi?cmd=file", content: xfer_data, headers: { \"Content-Type\": \"application/json; charset=utf-8\"}, load: function(data) { alert('Posted!' + data); }, error: function(error) { alert('Error! ' + error); } }; dojo.xhrPost(xhrArgs); </code></pre> <p>UPDATE..</p> <p>Modified the code for dojo version 1.8.1:</p> <pre><code>require(["dojo/request"], function(request){ var promise = request.post("/cgi-bin/DataExport.cgi", { data: xfer_data, timeout: 4000 }); promise.response.then(function(response){ var message = response.data; alert(message); }); }); </code></pre> <p>I still see nothing in $ENV{'QUERY_STRING'} on the server side. The request goes through but I still cannot find any JSON data??? </p> <pre><code>var xfer_data = [ {"ID":"1", "Device #":"176", "Access #":"002-20", "Address":"MH48 STEWART &amp; CRANDON", "TP":"MF", "Curr":" ", "Last":" ", "Tdy":"8.6", "-1":"8.6", "-2":"8.6", "-3":"8.6", "-4":"8.6", "-5":"8.6", "-6":"8.6", "Wk-1":"8.6", "Wk-2":"8.6", "Wk-3":"8.6", "Wk-4":"8.6", "Alarm":" R ", "In":"14"} ]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload