How to merge two json object using jQuery?
<p>I have two json objects data and foo, i want to merge them and create a single json object. The resultant json should have all the values from foo and the values from data. so far i have something like this </p>

<p><strong>javascript:</strong></p>

<pre><code>  $('#btn').click(function(){
            var imdbid=$('#tst').val();
            var url = "http://www.omdbapi.com/?i="+imdbid+"&amp;plot=full&amp;r=json"
            $.ajax({
            url:url,
            dataType:'json',
            success:function (json) {
                 data=json
                 var foo=$('form').serializeJSON() // store json string 
                 var marged=$.extend(data,foo);
                 console.log(marged);
                }
            })   
            }) 
</code></pre>

<p><strong>HTML:</strong></p>

<pre><code>&lt;form id="myform"&gt;
&lt;label&gt;imdb id:&lt;/label&gt;&lt;input type="text"  id="tst" name="tst"/&gt;&lt;/form&gt;&lt;br/&gt;
&lt;label&gt;comment:-&lt;/label&gt;&lt;input type="text" id="comment" name="comment" /&gt;&lt;br/&gt;
&lt;label&gt;link:-&lt;/label&gt;&lt;input type="text" name="link" id="link" /&gt;&lt;br/&gt;
&lt;input type="button" value="search"  id="btn"/&gt;
&lt;/form&gt;
</code></pre>

<p>the first object contains data returned from api and foo contains the values of form.i want to marge both object on a success function and send to php.
when i am trying to print out the data it's as follows </p>

<pre><code>{Title: "Mother's Day", Year: "2016", Rated: "PG-13", Released: "29 Apr 2016", Runtime: "118 min"…}
Actors
:
"Britt Robertson, Jennifer Aniston, Julia Roberts, Timothy Olyphant"
Awards
:

imdbID
:
"tt4824302"
tst
:
"tt4824302"
</code></pre>

<p>it's getting first input value not showing the second two. </p>