title: Cordova/PhoneGap rendering local PHP?
body: <p>I'm making a web using PhoneGap. I need to use a PHP page, but I want a real fluid website, so I opted for replacing a <code>div</code> with some PHP using JavaScript when loaded.</p>
  
  <p>When I launch the page "mypage.html" I check the user connection with this function:</p>
  
  <pre><code>     &lt;script&gt; 
          function checkConnection(){
  
     var online, speed;
     /*
     condizione di controllo per determinare se l'app viene correntemente testata 
     in un simulatore o dispositivo mobile (quindi utilizzando PhoneGap) o in un normale browser
     che supporta l'HTML5
     */
  
     if(typeof cordova != "undefined"){      
  
                  /*
         si tratta di un dispositivo vero e proprio o di un simulatore, quindi
         utilizziamo il plugin "Connection" messo a disposizione da Phonegap
         */
         var networkState = navigator.connection.type;  
         var states = {};
         states[Connection.UNKNOWN]  = 'Unknown';
         states[Connection.ETHERNET] = 'Ethernet';
         states[Connection.WIFI]     = 'WiFi';
         states[Connection.CELL_2G]  = 'Cell_2G';
         states[Connection.CELL_3G]  = 'Cell_3G';
         states[Connection.CELL_4G]  = 'Cell_4G';
         states[Connection.CELL]     = 'Cell_generic';
         states[Connection.NONE]     = 'None';
  
         //determino il tipo di connessione in base all'oggetto "states" appena definito grazie al plugin Phonegap
         var connType = states[networkState]; 
  
         if(connType=='None')
           online = false;
        else{
           online = true; 
           if(connType=="Cell_2g" || connType=="Cell_generic")
              speed="slow";
           else
              speed="fast";
         }
  
     }else{      
  
        /*
        si tratta di un normale browser desktop o mobile, quindi
        utilizziamo la funzionalità HTML5
        */
         online = navigator.onLine;
  
         if(online){
           var conn = navigator.connection || {'bandwidth':'0'};
           //utilizziamo il metodo "bandwidth" per determinare la velocità di connessione, il quale restituisce un valore numerico che indica la larghezza di banda della connessione corrente       
           if(conn.bandwidth&gt;2)
              speed="fast";
          else
           speed="slow";
  
         }
  
     }  
     return online?speed:false;
  
  }
  
  var deviceConnection = checkConnection();
  if(deviceConnection){
     if(deviceConnection == "slow"){
        //gestione connnessione lenta
  
     }else{
        //gestione connnessione veloce
  
  
     }
  }else{   
     /*
     gestione transizioni ed effetti per mostrare all'utente 
     un gradevole avviso di mancanza di connessione  
     */
     location.href="errorconnection.html"; 
  
  
  }
  
        &lt;/script&gt; 
  </code></pre>
  
  <p>This is the AJAX code : </p>
  
  <pre><code>&lt;div id="container"&gt;
   &lt;script&gt;
          $( "#container" ).load("http://www.mywebsite.org/FOLDER/page.php #container");
   &lt;/script&gt;  
  &lt;/div&gt; 
  </code></pre>
  
  <p>When I launch "mypage.html" on my browser locally it works ok, except for that it shows for a bit of php code. When I launch "mypage.html" on PhoneGap it shows me only a part of the php code and nothing else.</p>
  
  <pre><code>...
  
  &lt;/head&gt;
  &lt;body style="background-color:#e20a7e"&gt;
                                  &lt;div id="navigation"&gt;
                                      &lt;table width="100%"&gt;
                                          &lt;tr valign="bottom"&gt;
                                              &lt;td valign="middle" width="25%" align="center"&gt;
  
                                              &lt;/td&gt;
                                              &lt;td valign="bottom" width="50%" align="center"&gt;
                                                  &lt;img src="IMG/LOGO-WHITE.png" class="logonbar" alt="DONUT"/&gt;
                                              &lt;/td&gt;
                               &lt;td onClick="window.location='loginpage.php'" width="25%" align="center" valign="middle"&gt;
                                             &lt;img src="IMG/icon/usr.png" class="icons3"/&gt;
                                              &lt;/td&gt;
                                          &lt;/tr&gt;
                                      &lt;/table&gt;
  
                                  &lt;/div&gt;
  
  
                         &lt;div id="container"&gt;
  
  
  
      &lt;?php 
      $DBhost = "localhost";
      $DBuser = "xx";
      $DBpass = "";
      $DBName = "xx";
  
      $table = "Database";
  
      mysql_connect($DBhost,$DBuser,$DBpass) or die("mysql_error()");
      @mysql_select_db("$DBName") or die("mysql_error()");
  
  
  
      $sqlquery = "SELECT * FROM `Database` ORDER BY data DESC";
      $result = mysql_query($sqlquery);
      $number = mysql_num_rows($result);
  
  
  
      $i = 0;
  
      while ($i &lt; $number) {
  
            $festa[$i] = mysql_result($result,$i,"festa");
            $luogo[$i] = mysql_result($result,$i,"luogo");
            $idfesta[$i] = mysql_result($result,$i,"ID");
            $data[$i] = mysql_result($result,$i,"data");  
            $nomeimg[$i] = mysql_result($result,$i,"nomeimg");
  
            $data[$i] = data_eng_to_it_($data[$i]);
  
  
  
  
             echo"
                                       &lt;!--INIZIO DIV EVENTO--&gt;
  
                                      &lt;a href=\"pagevento.html?ID=$idfesta[$i]\"&gt;
                                      &lt;div style=\"width:90%; display:block; margin:0 auto; 
                                                      padding-top:10px; margin-top:10px; padding-left:10px;
                                                 background-color:#FFF; padding-bottom:10px; 
                                                 border-left:solid 5px #e20a7e;
  
  
                                                  -webkit-box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.7);
                                                  -moz-box-shadow:    0px 0px 10px 0px rgba(0, 0, 0, 0.7);
                                                  box-shadow:         0px 0px 10px 0px rgba(0, 0, 0, 0.7);\"&gt;
  
                                      &lt;table width=\"100%\" style='table-layout:fixed'&gt;
                                              &lt;tr valign=\"middle\"&gt;
                                                  &lt;td valign=\"middle\" align=\"center\" class=\"evntfoto\"
                                                       style=\"background-image:url(foto/$nomeimg[$i]);
                                                               background-position:center;
                                                             background-size: cover;\"&gt;
                                                  &lt;/td&gt;
                                                  &lt;td valign=\"top\"  align=\"left\" id=\"evnttxt\"&gt;
                                      &amp;nbsp; &amp;nbsp; &lt;font color=\"#0066FF\" size=\"+2\"&gt; &lt;b&gt; ".$festa[$i]." &lt;/b&gt;&lt;/font&gt; &lt;br&gt;
                                      &amp;nbsp; &amp;nbsp; ".$data[$i]."  &lt;br&gt;
                                      &amp;nbsp; &amp;nbsp; &lt;font color=\"#585858\"&gt; ".$luogo[$i]." &lt;/font&gt; &lt;br&gt;
                                                  &lt;/td&gt;
                                          &lt;/tr&gt;
                                          &lt;/table&gt;
                                              &lt;/div&gt;
                                              &lt;/a&gt;
  
                                       &lt;!--FINE DIV EVENTO--&gt; 
      ";
  
      $i++;
      }
      ?&gt;                      
                                      &lt;/div&gt;              
              &lt;/div&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>and when I run the page it shows me: </p>
  
  <pre><code>".$festa[$i]."
  ".$data[$i]."
  ".$luogo[$i]."
  
  "; $i++; ?&gt;
  </code></pre>
  
  <p>but only from PhoneGap. In other browsers, Safari on Mac, Google Chrome on Mac and Safari on iPhone it works correctly, and shows me that code for only a second. What could be the problem?</p>