Jquery Post multidimensional array via $.Ajax

ajax, jquery, multidimensional-array

Solution

Just put the field name in quotes, also notice I am using an object literal for the data parameter `{}` vs the parens you had in your question:

$.ajax({
    url: "/add/",
    type: "POST",
    data: { 'data[BlogPost][title]':'My New Title'} ,
    success: function(msg){
        alert(msg);
    }
});

Problem

I am trying to post an ajax call as if it were the following form element: ``` <input type="text" name="data[BlogPost][title]" /> ``` But I'm not having any luck here is my source: ``` $.ajax({ url: "/add/", type: "POST", data: ( /* what do I do here */), success: function(msg){ alert(msg); } }); ``` I've tried nested objects but that only generates a server response like: array 'data' => string '[object Object]' (length=15) Which does nobody any good! Any thoughts?

Original source