1

I have the following code which passes the code and objectIds to trailDesignations.action correctly.

            UpdateTrailDesignationGridClass = function(){
            this.updateTrailDesignationGrid = function(){

                var value1 = 35;
                var xhrArgs = {
                        url: "/trails/trailDesignations.action",
                        handleAs: "text",
                        preventCache: true,
                        content: {
                            code: value1,
                            objectIds: "35.36"
                        },
                        load: function(data){
                            featureResultsContent.innerHTML = data;
                        },
                        error: function(error){
                            featureResultsContent.innerHTML = "An unexpected error occurred: " + error;
                        }
                };

                // Call the asynchronous xhrGet
                var deferred = dojo.xhrGet(xhrArgs);

            };
        };

But since xhrGet is deprecated I am trying to do the same thing with dojo/request/xhr using the following code.

        UpdateTrailDesignationGridClass = function(){
            this.updateTrailDesignationGrid = function(){
                var value1 = 35;
                xhr("/trails/trailDesignations.action",{
                    data:{
                        code: value1,
                        objectIds: "35.36"
                    },
                    preventCache: true

                }).then(function(data){
                    featureResultsContent.innerHTML = data;
                },function(err){
                    featureResultsContent.innerHTML = "An unexpected error occurred: " + error;
                });

            };
        };

With the new code the data is not passed to the code and objectIds fields. I used the same Struts action in both cases.

        <action name="trailDesignations" class="gov.mo.dnr.tis.map.TrailDesignations">
        <result name="success" type="stream">
            <param name="contentType">text/html</param>
            <param name="inputName">inputStream</param>
        </result>
    </action>   

I did get information back from trailDesignations.action.

Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
ponder275
  • 903
  • 2
  • 12
  • 33

1 Answers1

1

You need to use query :{} for passing the payload... you can find the documentation @http://dojotoolkit.org/reference-guide/1.10/dojo/request/xhr.html for post request data : {} can be used.

xhr("/trails/trailDesignations.action",{
                query:{
                    code: value1,
                    objectIds: "35.36"
                },
                preventCache: true

            }).then(function(data){
                featureResultsContent.innerHTML = data;
            },function(err){
                featureResultsContent.innerHTML = "An unexpected error occurred: " + error;
            });
Srikant Sahu
  • 839
  • 1
  • 6
  • 16