Any ideas if it is possible to serialize HTML fields which are in a multi-dimensional array format for transmission over AJAX post?
Tried serializeArray and that formats 1 level of the array.
Data I need to serialize would be a series of name/value fields e.g.
name="customer" value="the value"
name="location" value="the location"
Using serializeArray() works fine on these e.g.
var formData = $('#createVacancy :input');
var serializedFormData = formData.serializeArray();
But some of the form data uses HTML array notation e.g.
name="tier[1][tiers][5][groupId]" value="5"
Result from serializeArray()
Normal name/value pairs comes through like Object { name="customer_name", value="Test customer name"}
But fields which use html array notation come through like:
Object { name="tier[1][publication_date]", value="03 Feb 2011"},
Object { name="tier[1][publication_date_db]", value="2011-02-03"},
Object { name="tier[1][tiers][5][groupId]", value="5"},
Object { name="tier[1][tiers][5][g开发者_运维知识库roupName]", value="Diamond"}
I'd have though this would need to be broken down into further objects.
Try using the JSON.stringify
method from json2.js.
try JSON_decode http://us.php.net/manual/en/function.json-encode.php
精彩评论