Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm also finding the dojoKit <a href="http://dojotoolkit.org/reference-guide/1.8/dojo/xhrPost.html" rel="nofollow">xhrPost</a> documentation a bit vague. But <code>content</code> accepts name, value pairs; and I think that it's supposed to post these back as form fields.</p> <p>It appears that the xhrPost method does not automatically serialize objects to JSON strings. To be safe, I'll do that first. I'm using the <code>dojo.toJson</code> method that I found documented <a href="http://dojotoolkit.org/reference-guide/1.7/dojo/toJson.html" rel="nofollow">here</a> and are assuming is avaliable.</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"} ]; var xfer_data_json = dojo.toJson( xfer_data ); var xhrArgs = { url: "/cgi-bin/DataExport.cgi?cmd=file", content: {data: xfer_data_json}, load: function(data) { alert('Posted!' + data); }, error: function(error) { alert('Error! ' + error); } }; dojo.xhrPost(xhrArgs); </code></pre> <p>The perl side then becomes regular CGI processing, with the need to deserialize JSON data (also untested):</p> <pre><code>#!/usr/bin/perl use warnings; use strict; use CGI; use JSON; my $cgi = CGI-&gt;new; if ($cgi-&gt;param('cmd') eq 'file') { my $data_json = $cgi-&gt;param('data'); my $devices = JSON::from_json( $data_json ); foreach my $device (@$devices) { printf ("device: id=%s access=%s address=%s\n", $device-&gt;{ID}, $device-&gt;{Access}, $device-&gt;{Address}); } } </code></pre>
 

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