neden bu ajax çağrı benim iç php okuyor değil mi?

4 Cevap php

Çok fazla takip düzenlemeleri, ama ben konuyu basitleştirilmiş var. Benim index.php bu kodu vardır:

<div class="calendar_top">
<?php
include(SITE_ROOT . "/includes/sub_top_divs.php"); ?>
</div>
<table class="tablebodycontainer"><tr><td>

<?php

    include(SITE_ROOT . "/includes/view-monthly-calendar-ajax.php");

?>
</td></tr></table>

<?php include(SITE_ROOT . "/includes/copyright.php"); ?>
</div>

Subtop Yukarıdaki gezinti bağlantılar içerir:

/ subtop-divs.php içerir:

<?php
    //include(SITE_ROOT . "/includes/set-variables.php");//dateFormat($date)
    echo "<table class='navtabs' cellpadding='0' cellspacing='0'>";
    echo "<tr><td class='right'>";
    echo buildMenuNavigation($currentPageIndex);
    echo '</td></tr></table>';
?>

İşte o buildMenuNavigation fonksiyonudur:

function buildMenuNavigation($currentIndex=0) {

  $navtabs = array(
  '0'=>array('Monthly'=>'index.php'),
  '1'=>array('Daily'=>'agenda.php'),
  '2'=>array('Admin'=>'admin/view-timelines.php'),
  '3'=>array('Help'=>'help.php'),
  );

  $sep = '<li>&nbsp;|&nbsp;</li>';$builtNav=array();
  foreach($navtabs as $index=>$tablinks) {  
    foreach($tablinks as $key=>$value)  {
      $class='';
      if($index==$currentIndex) {
        $class=' class="selected"';
      }
      //pr($value);
      $builtNav[] = '<li><a href="' . SITE_URL . '/' . $value.'"' . $class .'>&nbsp;'.$key.'&nbsp;</a></li>';
    }
  }
    return '<ul>' . implode($sep,$builtNav) . '</ul>';
}

Sayfaları değiştirirken aslında değiştirir tek veri yukarıda içeriği olan:

<?php

    include(SITE_ROOT . "/includes/view-monthly-calendar-ajax.php");

?>

Yani bu ajax için mükemmel bir aday gibi görünüyor.

Burada / includes / view-aylık-takvim-ajax.php içeriği olan:

<?php
$counter = 0; 
?>
<table class="tabbody">
  <tr>
    <td class='head unselectable'>Sun</td>
    <td class='head unselectable'>Mon</td>
    <td class='head unselectable'>Tue</td>
    <td class='head unselectable'>Wed</td>
    <td class='head unselectable'>Thu</td>
    <td class='head unselectable'>Fri</td>
    <td class='head unselectable'>Sat</td>
  </tr>
  <tr>
    <?php
    //echo $year."-".$month."-";
    $flag       =   0;
    $daysInrow  =   0;
    for($i = 1; $i < $numDays+1; $i++, $counter++)
    {
      $daysInrow++;
      $zero = "";
      if($i < 10)
      {
        $zero = "0";
      }

      $t_date  = $year."-".$month."-".$zero.$i;
      //$t_date         =   "$year-$month-$i";
      $timeStamp        =   strtotime($t_date);
      $eventID      =   0;
      $eventName        =   "&nbsp;";
      $bgColor      =   "";
      $funcBG           =   "setbgcolorMonth($i);";

      if($i == 1)
      {
        // Workout when the first day of the month is
        $firstDay = date("w", $timeStamp);

        for($j = 0; $j < $firstDay; $j++, $counter++)
        echo "<td class='tddaybox'></td>";
      }

      if($counter % 7 == 0)
      {
        $daysInrow = 1;
        echo "</tr><tr>";
      }

      if(date("w", $timeStamp) == 0)
        if($i == date("d") && $month == date("m") && $year == date("Y"))
              $class = "class='today'";
          else
            $class = "class='weekend'";
      else
      if($i == date("d") && $month == date("m") && $year == date("Y"))
      $class = "class='today'";
      else
      $class = "class='normal'";

     $numric_time =  getNumericTime($_SESSION['userData']['timezone']);//Get the numeric timezone

      $query            =   "SELECT *  FROM events  WHERE date(convert_tz(StartDate,'+00:00','". $numric_time."'))='".$t_date."' AND UserID='" . $_SESSION['userData']['UserID'] ."' ORDER BY PTLType ASC";
        //br();
      $result           =   mysql_query($query);
      if(mysql_num_rows($result))//cursor:hand;cursor:pointer;width:112px;
      {
        $funcBG     =   "";
        echo "<td valign='top' class='a_cursor_width tddaybox' id='day$i' onclick='setbgcolorMonth($i)'>";
        echo "<div class='td_overlow'>";
        echo '<table style="width:100%;border:0;">';
        echo '<tr class="rowColor"><td '.$class.'><div class="div_left"><a href="'.SITE_URL.'/agenda.php?date='.$year.'-'.$month.'-'.$zero.$i.'">'.$i.'</a></div><div class="div_left_80"  onclick="'.$funcBG.' get_event_popup(window.event, this, \''.SITE_URL.'/event-popup.php\', \'eventID='.$eventID.'\', \'date='.$date.'\', \'day='.$i.'\', \'type=M\');return false">&nbsp;</div></td></tr>';

        while($row = mysql_fetch_assoc($result))
        {
          $eventID  =   $row['EventID'];
          $parentEventID    =   $row['ParentEventID'];
          $eventName    =   stripslashes($row['EventName']);
          $PTLType  =   $row['PTLType'];
          $textclass    =   "title4";

          $onclick_call = 'get_event_popup(window.event, this, \''.SITE_URL.'/event-popup.php\', \'eventID='.$eventID.'\', \'date='.$date.'\', \'day='.$i.'\', \'type=M\')';

          if($PTLType   != 0)  {
            $onclick_call = 'get_event_popup(window.event, this, \''.SITE_URL.'/timeline-popup.php\', \'eventID='.$eventID.'\', \'parentEventID='.$parentEventID.'\', \'type=M\')';
            $bgColor    =   "";
            $textclass  =   "redtext";
            if($PTLType == 3)  {
              $textclass     =  "bluetext";
              $display  =   "none";
            }  else  {
              $display  =   "block";
            }
            $event_name_wrapped = '<div>'.$eventName.'</div>';
          }  else  {
            $textclass      =   "mainEvent";
            $display    =   "block";
            $event_name_wrapped = '<div>'.$eventName.'</div>';
          }

          echo '<tr><td onclick="'.$onclick_call.';return false;" class="'.$textclass.' a_cursor" title="'.$eventName.'" style="display:'.$display.';">'.$event_name_wrapped.'</td></tr>';
        }
        echo '<tr><td onclick="get_event_popup(window.event, this, \''.SITE_URL.'/event-popup.php\', \'eventID=0\', \'date='.$date.'\', \'day='.$i.'\', \'type=M\');return false;" class="a_cursor">&nbsp;</td></tr>';
        echo "</table>";
        echo "</div>";
        echo "</td>";
      }
      else
      {
        echo '<td id="day'.$i.'" height="80" valign="top" onclick="'.$funcBG.' get_event_popup(window.event, this, \''.SITE_URL.'/event-popup.php\', \'eventID='.$eventID.'\', \'date='.$date.'\', \'day='.$i.'\', \'type=M\');return false;" class="tddaybox a_cursor">';
        echo '<table style="width:100%;">';
        echo "<tr class='rowColor'><td $class>$i</td></tr>";
        echo "<tr><td>&nbsp;</td></tr>";
        echo "</table>";
        echo "</td>";
      }
    }

    for($l=0;$l<7-$daysInrow;$l++)
    {
      echo "<td class='tddaybox'>&nbsp;</td>";
    }
    ?>
  </tr>
</table>
<?php
/*
if(isset($divRed))
{
  $divRed   =   implode(",",$divRed);
  echo "<div id='divRed1' style='display:none'>$divRed</div>";
}
else
{
  echo "<div id='divRed1' style='display:none'>0</div>";
}
if(isset($divBlue))
{
  $divBlue= implode(",",$divBlue);
  echo "<div id='divBlue1' style='display:none'>$divBlue</div>";
}
else
{
  echo "<div id='divBlue1' style='display:none'>0</div>";
}
if(isset($divMainEvent))
{
  $divMainEvent=    implode(",",$divMainEvent);
  echo "<div id='divMainEvent1' style='display:none'>$divMainEvent</div>";
}
else
{
  echo "<div id='divMainEvent1' style='display:none'>0</div>";
}
*/
?> 

<div id='gig1' style='display:none'>0</div>
<div id='todo1' style='display:none'>0</div>
<div id='completed1' style='display:none'>1</div>


<input type="hidden" id='lastselectedday' value='' />

Yani yukarıdaki tüm çıktı şimdi doğru, ama denemek ve bunu yaparken:

<form>
<input type="button" value="Display Message" onclick="getData('/Dev2/includes/view-monthly-calendar-ajax.php', 'targetDiv')">
</form>
<table class="tablebodycontainer">
<tr>
<td id="MainCalendarContainer">
<div class="ajaxswap" id="targetDiv">

</div>

Ajax çağrısı çıktı php çalıştırmak değildir.

4 Cevap

Öncelikle, Ajax ile <script> elemanları çekme olmamalı, onlar yorumlanır olacak değildir ve eğer, onlar ikinci istek üzerine her şeyi kıracağız.

İlk /Dev2/includes/view-monthly-calendar-ajax.php tarayıcınızda arayarak bazı hata ayıklama yapmak. Eğer alıyorsanız ne kaynak kodunu kontrol edin. PHP belge teslim edilmeden önce çalışır, bu yüzden HTML çekmek için hiçbir yolu yoktur, ama not PHP tarafından oluşturulan içeriği. Onlar bir varlık vardır.

Sen orijinal PHP kaynak kodu belgenin kaynak kodunda (ki asla gerekir, çünkü noktaya kolay olan, yanlış çıkış yol açar, ya da PHP kodu tüm yorumlanır edilmediğinde PHP kodunda bir hata var ya hiç) olur.

PHP kodu sunucu tarafından işlenir; tarayıcı web sunucusu hataları olmadıkça onu görmek asla.

Veri istemciye gönderilmeden önce PHP önişlemdedir. Sunucu ayrıştırır ve çalıştırır php kodu ve sadece kod tarafından çıkış ne gönderir. Eğer tam dosya almak istiyorsanız bunu başka bir şey için dosya uzantısını yeniden adlandırarak, örneğin, php tarafından işlenir olması gerekir.

Başka bir php sayfası gibi uygulamak gerekir ...

 getData('getPHP.php?page=/Dev2/includes/view-monthly-calendar-ajax.php', 'targetdic');

Sonra bu sayfada size bir dize olarak php dosya yüklemek ve geri dönmek için bir yöntem uygulamak gerekir. Şu anda php beklediğiniz gibi yorumlanır ediliyor.