1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[jQuery]How to send associative array using ajax

Discussion in 'HTML & JavaScript' started by cyklotrial, Aug 20, 2009.

  1. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    Simple question:
    How to send associative array using ajax from jQuery lib?
     
    Last edited: Aug 20, 2009
  2. dukefx

    dukefx Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 8, 2009
    Messages:
    246
    Likes Received:
    109
    Occupation:
    VP Information Technology
    Location:
    Dagobah

    have you considered serializing the array?


    JS has no real associative arrays, only onobject properties.

    You have two options: 1) seralize the data

    2)
    get the object of the fields (paras):
    var all = new Object();
    $(?#admin_reportingSelector :input?).each(function(i){
    all[this.name]=this.value;
    });
    return(all);
    and then:
    $.post(loadResource,
    $.extend( { tableID: ?admin_reporting?, comboauswahl: comboboxingSelected, site: seite}, paras ),
    function(data) { verarbeiteGeladeneDaten(data); },
    ?html?);
    So there are some fields I set (tableID, comboauswahl, site) and the ones new ones!