<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic POST using dojo in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/post-using-dojo/m-p/578881#M54056</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to work through the dojo.xhrPost call to send some JSON data Example - &lt;/SPAN&gt;&lt;A href="http://livedocs.dojotoolkit.org/dojo/xhrPost" rel="nofollow noopener noreferrer" target="_blank"&gt;http://livedocs.dojotoolkit.org/dojo/xhrPost&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to post / send data to ESRI rest services/server.&amp;nbsp; I want to get this example working so I can move on and send things without using the editing tools.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm able to use Google Postman and get my post working properly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I�??m trying to construct some code to handle this.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I took the example and got it running as is.&amp;nbsp; Now I�??m trying to place my URL in the example and my content (post Data) in the example and get it running.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I attempt to do this I get confused on several points and I was hoping someone could explain these thing to me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The first one is in the header there is a script src='/_static/dojo/dojo.js'&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I had to change the script to use the full path name because it is not on my server.&amp;nbsp; So this made the example work. If I eliminate this script all together nothing happens so I'm wondering do I need this script, if so should I write my own or use the one in the example.&amp;nbsp; Not sure what&amp;nbsp; this is exactly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Next question is about the same thing but in the function.&amp;nbsp; In the example in the url it was referencing the above script.&amp;nbsp; I changed this to my rest end point but not sure if I also need to reference the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would someone be kind enough to explain to me what is going on and how I should more forward.&amp;nbsp; I'm green and have been stuck for a week or two now.&amp;nbsp; I'm wondering if anyone else has done anything similar.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html &amp;gt;
&amp;lt;head&amp;gt;

 &amp;lt;link rel="stylesheet" href="https://community.esri.com/_static/dojo/../dijit/themes/claro/claro.css"&amp;gt;
 
 &amp;lt;script&amp;gt;dojoConfig = {parseOnLoad: true}&amp;lt;/script&amp;gt;
 &amp;lt;script src='http://livedocs.dojotoolkit.org/_static/dojo/dojo.js'&amp;gt;&amp;lt;/script&amp;gt;&amp;nbsp; &amp;lt;!-- NOT SURE IF I SHOULD HAVE CHANGED THIS THE EXAMPLE IS src='/_static/dojo/dojo.js'--&amp;gt;
 
 &amp;lt;script&amp;gt;
dojo.require("dijit.form.Button");

function sendText(){
&amp;nbsp; var button = dijit.byId("submitButton2");

&amp;nbsp; dojo.connect(button, "onClick", function(event){
&amp;nbsp;&amp;nbsp;&amp;nbsp; // The parameters to pass to xhrPost, the message, and the url to send it to
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Also, how to handle the return and callbacks.
&amp;nbsp;&amp;nbsp;&amp;nbsp; var xhrArgs = {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; url: "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/0/applyEdits",&amp;nbsp;&amp;nbsp; // The example had the url as url: "/_static/dojo/../dojo/dojo.js",&amp;nbsp; NOT sure if I need /dojo/dojo.js
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; postData: dojo.toJson([{"geometry":{"x":-13085962.2699721,"y":4061306.82523268,"spatialReference":{"wkid":102100}},"attributes":{"description":"Test what","type":5}},{"geometry":{"x":-13072136.6421672,"y":4073467.58686212,"spatialReference":{"wkid":102100}},"attributes":{"description":"christineTeST","type":0}}]),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; handleAs: "text",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; load: function(data){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.byId("response2").innerHTML = "Message posted.";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; error: function(error){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // We'll 404 in the demo, but that's okay.&amp;nbsp; We don't have a 'postIt' service on the
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // docs server.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.byId("response2").innerHTML = "Message posted.";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.byId("response2").innerHTML = "Message being sent..."
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Call the asynchronous xhrPost
&amp;nbsp;&amp;nbsp;&amp;nbsp; var deferred = dojo.xhrPost(xhrArgs);
&amp;nbsp; });
}
dojo.ready(sendText);
 &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body class="claro"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;b&amp;gt;Push the button to POST some JSON.&amp;lt;/b&amp;gt;
&amp;lt;br&amp;gt;
&amp;lt;br&amp;gt;
&amp;lt;button data-dojo-type="dijit/form/Button" id="submitButton2"&amp;gt;Send it!&amp;lt;/button&amp;gt;
&amp;lt;br&amp;gt;
&amp;lt;br&amp;gt;
&amp;lt;b&amp;gt;Result&amp;lt;/b&amp;gt;
&amp;lt;div id="response2"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Christine&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 00:53:17 GMT</pubDate>
    <dc:creator>ChristineZeller</dc:creator>
    <dc:date>2021-12-12T00:53:17Z</dc:date>
    <item>
      <title>POST using dojo</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/post-using-dojo/m-p/578881#M54056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to work through the dojo.xhrPost call to send some JSON data Example - &lt;/SPAN&gt;&lt;A href="http://livedocs.dojotoolkit.org/dojo/xhrPost" rel="nofollow noopener noreferrer" target="_blank"&gt;http://livedocs.dojotoolkit.org/dojo/xhrPost&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to post / send data to ESRI rest services/server.&amp;nbsp; I want to get this example working so I can move on and send things without using the editing tools.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm able to use Google Postman and get my post working properly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I�??m trying to construct some code to handle this.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I took the example and got it running as is.&amp;nbsp; Now I�??m trying to place my URL in the example and my content (post Data) in the example and get it running.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When I attempt to do this I get confused on several points and I was hoping someone could explain these thing to me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The first one is in the header there is a script src='/_static/dojo/dojo.js'&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I had to change the script to use the full path name because it is not on my server.&amp;nbsp; So this made the example work. If I eliminate this script all together nothing happens so I'm wondering do I need this script, if so should I write my own or use the one in the example.&amp;nbsp; Not sure what&amp;nbsp; this is exactly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Next question is about the same thing but in the function.&amp;nbsp; In the example in the url it was referencing the above script.&amp;nbsp; I changed this to my rest end point but not sure if I also need to reference the script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would someone be kind enough to explain to me what is going on and how I should more forward.&amp;nbsp; I'm green and have been stuck for a week or two now.&amp;nbsp; I'm wondering if anyone else has done anything similar.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html &amp;gt;
&amp;lt;head&amp;gt;

 &amp;lt;link rel="stylesheet" href="https://community.esri.com/_static/dojo/../dijit/themes/claro/claro.css"&amp;gt;
 
 &amp;lt;script&amp;gt;dojoConfig = {parseOnLoad: true}&amp;lt;/script&amp;gt;
 &amp;lt;script src='http://livedocs.dojotoolkit.org/_static/dojo/dojo.js'&amp;gt;&amp;lt;/script&amp;gt;&amp;nbsp; &amp;lt;!-- NOT SURE IF I SHOULD HAVE CHANGED THIS THE EXAMPLE IS src='/_static/dojo/dojo.js'--&amp;gt;
 
 &amp;lt;script&amp;gt;
dojo.require("dijit.form.Button");

function sendText(){
&amp;nbsp; var button = dijit.byId("submitButton2");

&amp;nbsp; dojo.connect(button, "onClick", function(event){
&amp;nbsp;&amp;nbsp;&amp;nbsp; // The parameters to pass to xhrPost, the message, and the url to send it to
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Also, how to handle the return and callbacks.
&amp;nbsp;&amp;nbsp;&amp;nbsp; var xhrArgs = {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; url: "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/0/applyEdits",&amp;nbsp;&amp;nbsp; // The example had the url as url: "/_static/dojo/../dojo/dojo.js",&amp;nbsp; NOT sure if I need /dojo/dojo.js
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; postData: dojo.toJson([{"geometry":{"x":-13085962.2699721,"y":4061306.82523268,"spatialReference":{"wkid":102100}},"attributes":{"description":"Test what","type":5}},{"geometry":{"x":-13072136.6421672,"y":4073467.58686212,"spatialReference":{"wkid":102100}},"attributes":{"description":"christineTeST","type":0}}]),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; handleAs: "text",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; load: function(data){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.byId("response2").innerHTML = "Message posted.";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; error: function(error){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // We'll 404 in the demo, but that's okay.&amp;nbsp; We don't have a 'postIt' service on the
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // docs server.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.byId("response2").innerHTML = "Message posted.";
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.byId("response2").innerHTML = "Message being sent..."
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Call the asynchronous xhrPost
&amp;nbsp;&amp;nbsp;&amp;nbsp; var deferred = dojo.xhrPost(xhrArgs);
&amp;nbsp; });
}
dojo.ready(sendText);
 &amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body class="claro"&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;b&amp;gt;Push the button to POST some JSON.&amp;lt;/b&amp;gt;
&amp;lt;br&amp;gt;
&amp;lt;br&amp;gt;
&amp;lt;button data-dojo-type="dijit/form/Button" id="submitButton2"&amp;gt;Send it!&amp;lt;/button&amp;gt;
&amp;lt;br&amp;gt;
&amp;lt;br&amp;gt;
&amp;lt;b&amp;gt;Result&amp;lt;/b&amp;gt;
&amp;lt;div id="response2"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Christine&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:53:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/post-using-dojo/m-p/578881#M54056</guid>
      <dc:creator>ChristineZeller</dc:creator>
      <dc:date>2021-12-12T00:53:17Z</dc:date>
    </item>
  </channel>
</rss>

