Following on this post, I have another problem – how can I combine two json data objects?
first json object,
{"file":{"name":"1024x768.jpg","type":"image\/jpeg","tmp_name":"C:\\wamp\\tmp\\php2C2E.tmp","error":0,"size":469159}}
second json object,
{"title":"title","content":"bla bla blah"}
$.post("process.php", first + second ,function(xml){
});
So I can get this array in process.php using print_r($_POST):
Array
(
[file] => Array
(
[name] => 1024x768.jpg
[type] => image/jpeg
[tmp_name] => C:\wamp\tmp\phpA1.tmp
[error] => 0
[size] => 469159
)
[title] => title
[content] => bla bla blah
)
Looking at your first data object
fileis not an array as you are expecting it in the server sidephpcode. It is aJSONobject. Anyways you can try this to combine the data objects and post it.Alternatively you can use
jQuery.extendmethod which merge the contents of two or more objects together into the first object.