Opened 13 years ago

Last modified 11 years ago

#5906 closed enhancement

problems with dojo.objectToQuery — at Initial Version

Reported by: guest Owned by: anonymous
Priority: high Milestone: future
Component: Core Version: 1.0
Keywords: xhr, ajax, post, object, Cc: [email protected]
Blocked By: Blocking:

Description

In order to be able to post AJAX queries like this:

eID=tx_t3dojo_model&tx_t3dojo_type=t3dojo_grid&tx_t3dojo[t3dojo_query_connector]=test_connector&tx_t3dojo[command]=info

a javascript parameter with sub objects needs to be converted correctly

var param =  {
              eID: this.eID,
              tx_t3dojo: {
                      t3dojo_query_connector: this.T3DojoQueryConnector
              }
        };

The change below would do the trick:

dojo.objectToQuery = function(/*Object*/ map){


        var ec = encodeURIComponent;
        var ret = "";
        var backstop = {};
        for(var x in map){
            if(map[x] != backstop[x]){
                if(_d.isArray(map[x])){
                    for(var y=0; y<map[x].length; y++){
                        ret += ec(x) + "=" + ec(map[x][y]) + "&";
                    }
                } /*change achim gerber */ else if(_d.isObject(map[x])){
                    for(var y in map[x]){
                        ret += ec(x) + "[" + ec(y) + "]" + "=" + ec(map[x][y]) + "&";
                    }
                } /* end change achim gerber */else{
                    ret += ec(x) + "=" + ec(map[x]) + "&";
                }
            }
        }
        if(ret.length && ret.charAt(ret.length-1) == "&"){
            ret = ret.substr(0, ret.length-1);
        }
        return ret; // String
    }

Greetings - Achim

Change History (0)

Note: See TracTickets for help on using tickets.