Following on this post, I have another problem - how can I combine two json data objects?
first json object,
{\"file\":{\"name\":\"1024x768.jpg\",\"t
Use $.extend:
$.post("process.php", $.extend(true, first, second) ,function(xml){
});
Looking at your first data object file
is not an array as you are expecting it in the server side php
code. It is a JSON
object. Anyways you can try this to combine the data objects and post it.
var data1 = {"file":{"name":"1024x768.jpg","type":"image\/jpeg","tmp_name":"C:\\wamp\\tmp\\php2C2E.tmp","error":0,"size":469159}};
var data2 = {"title":"title","content":"bla bla blah"}
var data = data1;
data.title = data2.title;
data.content = data2.content;
$.post("process.php", data ,function(xml){
});
Alternatively you can use jQuery.extend
method which merge the contents of two or more objects together into the first object.
var data1 = {"file":{"name":"1024x768.jpg","type":"image\/jpeg","tmp_name":"C:\\wamp\\tmp\\php2C2E.tmp","error":0,"size":469159}};
var data2 = {"title":"title","content":"bla bla blah"}
$.post("process.php", $.extend({}, data1, data2) ,function(xml){
});