I have this being POSTed to my script
Array
(
[0] => Array
(
[name] => test1
[value] => test1 value
)
[1] => Array
(
[name] => test2
[value] => test2 value
)
)
What I want is:
Array
(
[0] => Array
(
[test1] => test1 value
)
[1] => Array
(
[test2] => test2 vlaue
)
)
This is the JQuery I am using to post the data. Can someone tell me what I need to achieve this?
var vals = $("#post").find('input,select,textarea').serializeArray();
vals.push({
name: 'article',
value: CKEDITOR.instances.article.getData()
});
var qs = $.param(vals);
$.post('test.php', {
data: vals
}, function (data) {
if(data.success == 0) {
}
}, 'json');
EDIT:
What I am looking to do is to simply access each key value on my server like this:
echo $_POST['test1'];
...
When using
$.post, the 2nd param is the data you want to send to the server. It’s not like$.ajaxwhere you pass an object with options in it.Try this: