übergeben eines Arrays in json.stringify

Ich versuche die übergabe eines Arrays in json.stringify aber der zurückgegebene Wert kommt leer wieder zurück.

JSON.stringify({ json: data }) //returns `{"json":[]}`

Und hier wäre der Inhalt von data:

data[from] = "[email protected]"
data[to] = "[email protected]"
data[message] = "testmessage"

jquery:

function SubmitUserInformation($group) {
    var data = {};
    data = ArrayPush($group);
    $.ajax({
        type: "POST",
        url: "http://www.mlaglobal.com/components/handlers/FormRequestHandler.aspx/EmailFormRequestHandler",
        data: JSON.stringify({ json: data }),
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        cache: false,
        success: function (msg) {
            if (msg) {
                $('emailForm-content').hide();
                $('emailForm-thankyou').show();
            }
        },
        error: function (msg) {
            form.data("validator").invalidate(msg);
        }
    });
}

function ArrayPush($group) {
    var arr = new Array();
    $group.find('input[type=text],textarea').each(function () {
        arr[$(this).attr('id')] = $(this).val();
    });
    return arr;
}
InformationsquelleAutor bflemi3 | 2012-01-20
Schreibe einen Kommentar