title: get json response with php
body: <p>Im trying to use an api I was given to create a instant quote form. The form should be getting info from a form and sent to the url and respond using JSON. I've personally have only ever use JSON once but not in this way so I really don't know what Im doing right or wrong. Any help is musch appreciated. </p>
  
  <p>this is my form_post.php</p>
  
  <pre><code>&lt;?php
  $key1=$_POST['key1'];
  $First_Name=$_POST['First_Name'];
  $Last_Name=$_POST['Last_Name'];
  $Company_Name=$_POST['Company_Name'];
  $Email=$_POST['Email'];
  $Phone_1=$_POST['Phone_1'];
  $Phone_2=$_POST['Phone_2'];
  $Phone_Fax=$_POST['Phone_Fax'];
  $Address_1=$_POST['Address_1'];
  $Address_2=$_POST['Address_2'];
  $Address_City=$_POST['Address_City'];
  $Address_State=$_POST['Address_State'];
  $Address_Zipcode=$_POST['Address_Zipcode'];
  $Note=$_POST['Note'];
  $Carrier=$_POST['Carrier'];
  $Origin_City=$_POST['Origin_City'];
  $Origin_State=$_POST['Origin_State'];
  $Origin_Zipcode=$_POST['Origin_Zipcode'];
  $Destination_City=$_POST['Destination_City'];
  $Destination_State=$_POST['Destination_State'];
  $Destination_Zipcode=$_POST['Destination_Zipcode'];
  $v_year=$_POST['v_year'];
  $v_make=$_POST['v_make'];
  $v_model=$_POST['v_model'];
  $v_op=$_POST['v_op'];
  $v_size=$_POST['v_size'];
  $Available_Date=$_POST['Available_Date'];
  $url = 'https://www.transportautoquoter.com/ws/abd/v1/createQuote/';
  $data = array('quote_id' =&gt; $quote_id, 'vehicle_count' =&gt; $vehicle_count 'deposit' =&gt; $deposit 'total' =&gt; $total 'price' =&gt; $price);
  $options = array(
      'http' =&gt; array(
          'header'  =&gt; "Content-type: application/x-www-form-urlencoded\r\n",
          'method'  =&gt; 'POST',
          'content' =&gt; http_build_query($data)
      )
  );
  $context  = stream_context_create($options);
  $response = file_get_contents($url, false, $context);
  if ($response === FALSE) { /* Handle error */ }
    $json_array=json_decode($response,true); 
   function display_array_recursive($json_rec){
          if($json_rec){
              foreach($json_rec as $price=&gt; $value){
                  if(is_array($value)){
                      display_array_recursive($value);
                  }else{
                      echo $price.'--'.$value.'&lt;br&gt;';
                  }   
              }   
          }   
      }
      display_array_recursive($json_array);
  ?&gt;
  </code></pre>
  
  <p>this is my script on the index.php doc</p>
  
  <pre><code>&lt;script&gt;
        function submit_by{
          var First_Name=$("#First_Name").val();
          var Last_Name=$("#Last_Name").val();
          var Company_Name=$("#Company_Name").val();
          var Email=$("#Email").val();
          var Phone_1=$("#Phone_1").val();
          var Phone_2=$("#Phone_2").val();
          var Phone_Fax=$("#Phone_Fax").val();
          var Address_1=$("#Address_1").val();
          var Address_2=$("#Address_2").val();
          var Address_State=$("#Address_State").val();
          var Address_Zipcode=$("#Address_Zipcode").val();
          var Note=$("#Note").val();
          var Carrier=$("#Carrier").val();
          var Origin_City=$("#Origin_City").val();
          var Origin_State=$("#Origin_State").val();
          var Origin_Zip=$("#Origin_Zip").val();
          var Destination_City=$("#Destination_City").val();
          var Destination_Sate=$("#Destination_Sate").val();
          var Destination_Zip=$("#Destination_Zip").val();
          var v_year=$("#v_year").val();
          var v_make=$("#v_make").val();
          var v_model=$("#v_model").val();
          var v_op=$("#v_op").val();
          var v_size=$("#v_size").val();
          var Available_Date=$("#Available_Date").val(); 
          $.post("form_post.php",{"Api_key":"itmzsxrolybe","Api_pin":"2631",”Referrer_Id”:”8”,"Shipper":{"First_Name":"First_Name","Last_Name":"Last_Name","Company_Name":"Company_Name","Email":"Email","Phone_1":"Phone_1","Phone_2":"Phone_2","Phone_Mobile":"Phone_Mobile","Phone_Fax":"Phone_Fax","Address_1":"Address_1","Address_2":"Address_2","Address_City":"Address_City","Address_State":"Address_State","Address_Zipcode":"Address_Zipcode","Note":"Note"},"Transport":{"Carrier":"Carrier","Origin":{"City":"Origin_City","State":"Origin_State","Zipcode":"Origin_Zip"},"Destination":{"City":"Destination_City","State":"Destination_Sate","Zipcode":"Destination_Zip"},"Vehicles":[{"v_year":"v_year","v_make":"v_make","v_model":"v_model","veh_op":"veh_op","v_size":"v_size"}],"Available_Date":"Available_Date"}},
          function(data){
            $("#json_response").html(data);
          });
      }
      &lt;/script&gt;
  </code></pre>
  
  <p>Im not sure why the page seems to refresh and not show response?</p>