title: Include API call inside a page to load lazy
body: <p>I am calling an API to another service on this "form" page.</p>
  
  <p>Most of the time the API call to the other service is slow.. and it takes 2-4 refreshes of the browser to complete the call.</p>
  
  <p>My problem is:</p>
  
  <p>I have a dropdown select menu populating from the API call:</p>
  
  <blockquote>
  <pre><code>      &lt;select name="memberID" id="memberID"&gt;
             &lt;?
               if(!empty($organization_list))
             {
                 foreach($organization_list as $memberID=&gt;$companyName)
                 {
  
                   $s = "";
                   if($offer['memberID'] == $memberID || $_GET['m'] == $memberID) $s = " selected";
                   echo "&lt;option value='".$memberID."' $s&gt;".stripslashes($companyName)."&lt;/option&gt;";
  
                 }
                }
             ?&gt; 
            &lt;/select&gt;
  </code></pre>
  </blockquote>
  
  <p>And obviously including the API function above..</p>
  
  <p>Since this is the only SELECT / DROPDOWNN menu on the page that call from another API Service, it loads the first 2-3 times empty...</p>
  
  <p>Is there a way I can have this select menu keep loading until fully finished while everything else on the page has loaded... </p>
  
  <p>I don't want the entire page to be stalled because of this dropdown... ?</p>
  
  <p>Thanks in advance NINJAS!!</p>
  
  <p>Here is the API call :</p>
  
  <blockquote>
    <p>ini_set ('max_execution_time', 3000); 
    {     print_r("<pre>");   print_r($data); }</p>
  
  <p>define("API_KEY",'XXX'); define("ACCOUNT_ID",'XXX');</p>
  
  <p>/**
  ** This method is used for the get company list or contact or member 
  ** Param<br>
  */  function get_organization_list() {    $api_key = API_KEY;     $account_id = ACCOUNT_ID;       $organization_list = array();</p>
  
  <pre><code>  $url =
  </code></pre>
    
    <p>"<a href="https://api.wildapricot.org/v1/Accounts/" rel="nofollow">https://api.wildapricot.org/v1/Accounts/</a>$account_id/Contacts?apikey=$api_key";
      $public_contact_member  = file_get_contents($url);
                  $json_decode_arr = json_decode($public_contact_member);         //pr($json_decode_arr);
              if(!empty($json_decode_arr))    {        $json_decode_arr->ResultUrl;
                  $url = '';      $url = $json_decode_arr->ResultUrl;         $url = $url."&amp;apikey=".$api_key;
                   $public_contact_member_list  = file_get_contents($url);
                   $json_decode_arr = json_decode($public_contact_member_list);
                   $json_decode_arr = ( array ) $json_decode_arr ;
                      //pr($json_decode_arr);
                  // Contacts         // $json_decode_arr["Contacts"];
                  if( isset($json_decode_arr["Contacts"]) and !empty($json_decode_arr["Contacts"]) and
    !isset($_SESSION["json_decode_arr"]))         {
               $_SESSION["json_decode_arr"] = $json_decode_arr;       }
                  if(isset($_SESSION["json_decode_arr"]) and !empty($_SESSION["json_decode_arr"]))        {
               $json_decode_arr = $_SESSION["json_decode_arr"] ;
                          // pr($_SESSION["json_decode_arr"]);        }
                  if(!empty($json_decode_arr["Contacts"]))        { 
               $size_of_array = count($json_decode_arr["Contacts"]);
                          for($i=0;$i
                      $array_field = (array)  $json_decode_arr["Contacts"][$i]->FieldValues;<br>
                  //  pr( $array_field );             </p>
  
  <code>           $value_get = 16;
             $orgranization_id = $array_field[$value_get]-&gt;Value;
  
             $value_get = 17;
             $orgranization_name = $array_field[$value_get]-&gt;Value;
  
            if($orgranization_name!="")
            {
  
              $member_id='';
  
                for($jk=0; $jk&lt;count($array_field); $jk++)
                {
                    if($member_id=="")
                    {
                        $filed_name = $array_field[$jk]-&gt;FieldName;
                        if($filed_name=="Member ID")
                        {
                             $member_id = $array_field[$jk]-&gt;Value;
                            //echo '&lt;br/&gt;';
                        }
                    }
                }
  
  
                if(isset($member_id) and $member_id!='')
                {
                    $organization_list[$member_id] = $orgranization_name;
  
                }else{
  
                    $organization_list[$orgranization_id] = $orgranization_name;
  
                }
            }
  
                        }       }
  
            }
        asort($organization_list);      return $organization_list;
  </code></pre>
    
    <p>}</p>
  </blockquote>