[Answered ]-Send JSON object via POST from JavaScript to Python

2👍

dojo.xhr has been deprecated, please consider using dojo/request more info here:

https://dojotoolkit.org/reference-guide/1.10/dojo/request/xhr.html#dojo-request-xhr

For a live example of post to a server, you can look source code for this page:
https://dojotoolkit.org/documentation/tutorials/1.8/ajax/demo/dojo-request-xhr-post.php

Here some a simple example of usage:

        require(dojo/request"],
            function(request){
                    // post the data to the server
                    request.post("your/server/script", {
                        // send your data here
                        data: { yourData: 1},
                        // wait 2 seconds for a response
                        timeout: 2000

                    }).then(function(response){
                        // do smt here when operation is successfully executed
                    });

            }
        );

Regarding your code sample in your question, you have’t posted your server side code. But you could try to pass your data to the server using JSON.stringify().

👤GibboK

Leave a comment