Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Help with Post

  1. #1
    jsd
    jsd is offline
    New to the CF scene
    Join Date
    Oct 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with Post

    I'm trying to Send some information to a cloud service (perform a Post).

    I'm able to get the post to work using Google POSTMAN and now I'm trying to construct my javascript to handle it.

    I'm currently using dojo but willing to try something else (ajax, jquery, or straight JS).

    I can't seem to figure out why my code is doing nothing. It's like my button click it not responding at all.

    Code:
    <!DOCTYPE html>
    <html >
    <head>
    
                    <link rel="stylesheet" href="/_static/dojo/../dijit/themes/claro/claro.css">           
    
                    <script>dojoConfig = {parseOnLoad: true}</script>
    
                    <script>
    
    dojo.require("dijit.form.Button");
    
    function sendText(){
    
      var button = dijit.byId("submitButton2");
    
    var myParameters= ({ "data":[{ "key":"manhole_work_order_number", "vaule":"JAYPOST_iforms" },{ "key":"manhole_id", "value":"MH-JPM-0001" "type":"text" },{ "key":"notes", "value":"THIS IS A POST" "type":"text" }]});
    
     
      dojo.connect(button, "onClick", function(event){
            var xhrArgs = {
                            url: "https://dudek.iformbuilder.com/exzact/api/profiles/151815/pages/291072/records?ACCESS_TOKEN=d790ba2daf596e6ee881f367f056dcc918e7e4c8&VERSION=5.1",
                            postData: dojo.toJson(myParameters),
    
                            handleAs: "text",
    
                            headers: { "Content-Type": "application/json", "Accept": "application/json" },
    
                            load: function(data) {
                            },
                            error: function(error) {
    
                            }
                        }
    
    var deferred = dojo.xhrPost(xhrArgs);
    dojo.ready(sendText);
                    </script>
    </head>
    <body class="claro">
        <b>Push the button to POST some JSON.</b>
    <br>
    <br>
    <button data-dojo-type="dijit/form/Button" id="submitButton2">Send it!</button>
    <br>
    <br>
    <b>Result</b>
    <div id="response2"></div>
    </body>
    </html>


    I was also trying this with the same results

    Code:
    <!DOCTYPE html>
    <html >
    <head>
    
    	<link rel="stylesheet" href="../_static/js/dojo/../dijit/themes/claro/claro.css">
    	
    	<script>dojoConfig = {parseOnLoad: true}</script>
    	
    	
    	<script>
    dojo.require("dijit.form.Button");
    
    function sendText(){
      var button = dijit.byId("submitButton2");
    
      dojo.connect(button, "onClick", function(event){
        // The parameters to pass to xhrPost, the message, and the url to send it to
        // Also, how to handle the return and callbacks.
        var xhrArgs = {
          url: "https://dudek.iformbuilder.com/exzact/api/profiles/151815/pages/291072/records?
    
    ACCESS_TOKEN=d790ba2daf596e6ee881f367f056dcc918e7e4c8&VERSION=5.1",
          postData: "{ "data":[{ "key":"manhole_work_order_number", "vaule":"JAYPOST_iforms" },{ 
    
    "key":"manhole_id", "value":"MH-JPM-0001" "type":"text" },{ "key":"notes", "value":"THIS IS A POST" 
    
    "type":"text" }]}",
          handleAs: "text",
          load: function(data){
            dojo.byId("response2").innerHTML = "Message posted.";
          },
          error: function(error){
            // We'll 404 in the demo, but that's okay.  We don't have a 'postIt' service on the
            // docs server.
            dojo.byId("response2").innerHTML = "Message posted.";
          }
        }
        dojo.byId("response2").innerHTML = "Message being sent..."
        // Call the asynchronous xhrPost
        var deferred = dojo.xhrPost(xhrArgs);
      });
    }
    dojo.ready(sendText);
    	</script>
    </head>
    <body class="claro">
        <b>Push the button to POST some text.</b>
    <br>
    <br>
    <button data-dojo-type="dijit/form/Button" id="submitButton2">Send it!</button>
    <br>
    <br>
    <b>Result</b>
    <div id="response2"></div>
    </body>
    </html>
    Thanks

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,378
    Thanks
    11
    Thanked 592 Times in 572 Posts
    this dojo stuff is wierd, and i don't know of anyone on here that sports it.
    if you can should us a redacted but working html form example, we can show you how to use ajax to do the same thing as the form in the background...
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •