title: Pass multiple php arrays in ajax request response
body: <p>I'm trying to pass multiple arrays in Ajax request response(get), but unfortunately I'm not able to get it done.</p>
  
  <p>This is my php code I'm willing to send into Ajax request response:</p>
  
  <pre><code>echo json_encode($catdata);
  echo json_encode($productdata);
  echo json_encode($data);
  </code></pre>
  
  <p>My js ajax call is:</p>
  
  <pre><code>$.ajax({
      type: "post",
      url: "../api/test.php",
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      success: function(data){
          var j=0;
          $.each(data,function(l,item){
              var arrlength = data[l].countdest;
              while(j&lt;=arrlength)
              {
                  (function(j)
                  {
                      $('#catbtn').click(function(){
                          if(j&lt;=arrlength)
                          {
                              $('#resultdiv').append('&lt;p name="destinationid"&gt;'+data[j].destinationid+' '+data[j].name+'&lt;/p&gt;');
                              var a;
                              for(a=0;a&lt;4;a++)
                              {
                                  alert(a);
                              }
                              //$('#resultdiv').append('&lt;input type="checkbox" name="destinationid" value="'+data[j].destinationid+'" '+data[j].name+'/&gt;');
                              j++;
                              if(j==arrlength)
                              {
                                  $('#catbtn').hide();
                                  $('#submit').show();
                              }
                          }
                      });
                  }
                  (j));
                  i
              }
          });
          //alert(arrlength);
      },
  });
  </code></pre>