xmlhttp.responsetext is null

Discussion in 'JavaScript' started by Sleeping Troll, Sep 2, 2008.

  1. #1
    This is the code, problem is the xmlHttp.responsetext comes up null.



    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Admin Default</title> 
    <?php
    $conn = mysql_connect("xxx","xxx","xxx"); 
    mysql_select_db("xxx",$conn);
    ?>
    <script type="text/javascript">
    <!--
    var xmlHttp;
    function Init()
    {
       try
         {  // Firefox, Opera 8.0+, Safari
          xmlHttp=new XMLHttpRequest();
         }
         catch (e)
           {  // Internet Explorer
            try
              {
              xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
              }
               catch (e)
                {
                try
                   {
                    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                   }
                   catch (e)
                     {
                      alert("Your browser does not support AJAX!");
                    }
              }
           }
    }
     
    [COLOR="Orange"]function NewCat(Elem)
    {
    Init();
     var Title = prompt("Please enter title for new category");
    xmlHttp.onreadystatechange=function()
       {
      if(xmlHttp.readyState==4)
       {
       [COLOR="Olive"]document.getElementById(Elem).innerHTML = xmlHttp.responseText;[/COLOR]
         }
       }
      ReqStr = "NewCat.php?Title=" + encodeURI(Title);
      xmlHttp.open("Get",ReqStr,true);
      xmlHttp.send(null);
    }[/COLOR]
    //-->
    </script>
    <style type="text/css">
    <!--
    .style1 {
    font-family: "GrilledCheese BTN";
    font-size: large;
    }
    .style2 {
    font-family: "GrilledCheese BTN";
    font-size: x-small;
    }
    .style3 {font-family: "GrilledCheese BTN"}
    a:hover {
    font-family: "GrilledCheese BTN";
    font-size: larger;
    color: #000000;
    }
    body {
    background-color: #FDF993;
    }
    a:link {
    color: #000000;
    text-decoration: none;
    }
    dl, dt, dd, ul, li {
    margin: 0;
    padding: 0;
    list-style-type: none;
    }
    .style8 {font-family: "GrilledCheese BTN"; font-size: small; }
    a:visited {
    color: #000000;
    }
    a:active {
    color: #000000;
    }
    -->
    </style>
    <body>
    <table width="100%" border="0">
    <tr>
              <!-- Bumper -->
      <td>&nbsp;</td>
              <!-- Bumper -->
              <!-- Login Panel Start -->
      <td width="120" align="center" class="style3" id = "Message">
      <div align="center"><?php echo $Msg ?></div></td>
              <!-- Login Panel End -->
              <!-- Bumper -->
      <td>&nbsp;</td>
              <!-- Bumper -->
              <!-- Banner Panel Start -->
      <td id = "Banner" align="center" height="120">
       <div><img src="../Images/Bnnr.png" width="700" height="91"></div>
      </td>
              <!-- Banner Panel End -->
              <!-- Bumper -->
     
      <td>&nbsp;</td>
     
              <!-- Bumper -->
              <!-- Navigation Panel Start -->
      <td width="120" align="center" valign="middle" nowrap id = "Navigation">
       <div class = "style2">
         <a href = "default.php">Home</a><br>
         <a href = "FAQ.php">FAQ</a><br>
         <a href = "Contact.php">Contact Us</a><br>
         <a href = "About.php">About us</a><br>
         <a href = "Cart.php">My Cart</a><br>
       </div>
      </td>
              <!-- Navigation Panel End -->
     
              <!-- Bumper -->
      <td>&nbsp;</td>
              <!-- Bumper -->
    </tr>
    </table>
    <table width="100%"> 
    <tr>
              <!-- Left Panel Start -->
      <td width="200" colspan="4" align="center" valign="top" nowrap id = "Left_Panel">
       <div class = "style1">
        <div align="center">Categories</div>
        <div align="center"></div> 
       </div>  </td>
              <!-- Left Panel End -->
              <!-- Center Panel Start -->
      <td colspan="5" align="center" valign="top" id = "Center_Panel">
       <div class="style1">
        <div align="center">Templates</div>
        <div align="center">   </div>  </td>
              <!-- Center Panel End -->
     
              <!-- Right Panel Start -->
      <td width="400" align="center" valign="top" nowrap id = "Right_Panel">
       <div class="style1">Preview Image </div>  </td>
              <!-- Right Panel End -->
    </tr>
    <tr>
       <td align="center" valign="top" nowrap class="style8" id = "Left_Panel">&nbsp;</td>
      <td align="center" valign="top" class="style8" id = "Center_Panel"><div align="right">
       <div align="left">Title</div>
       </div></td>
      <td align="center" valign="top" class="style8" id = "Center_Panel"><div align="right">Status</div></td>
      <td align="center" valign="top" class="style8" id = "Center_Panel">&nbsp;</td>
      <td align="center" valign="top" nowrap class="style8" id = "Right_Panel">File Name </td>
      <td align="center" valign="top" nowrap class="style8" id = "Right_Panel">Text Fields </td>
      <td align="center" valign="top" nowrap class="style8" id = "Right_Panel">Categories</td>
      <td align="center" valign="top" nowrap class="style8" id = "Right_Panel">Photos</td>
      <td align="center" valign="top" nowrap class="style8" id = "Right_Panel">Enable</td>
    </tr>
    <tr>
      <td align="center" valign="top" nowrap id = "Left_Panel">&nbsp;</td>
      <td colspan="2" align="center" valign="top" nowrap id = "Left_Panel">
    [COLOR="Blue"]<table id= "Categories" name= "Categories" width="100%"[/COLOR] align = "center" border="0">
       <?php
    $SQL = "Select * From Categories";
    $result = mysql_query($SQL);
    while($row = mysql_fetch_array($result))
    {
    echo (" 
       <tr> 
        <td><div class = 'style8' align = 'left'>".$row['Title']."</div></td>
        <td><div class = 'style8' align = 'right'>".$row['Enable']."</div></td>
       </tr>
       ");
    }
    ?>
      </table></td>
      <td align="center" valign="top" nowrap id = "Left_Panel">&nbsp;</td>
      <td colspan="5" align="center" valign="top" id = "Center_Panel">
    <table id= 'Templates' width='100%' align = 'center' border='0'>
    <?php
    $SQL = "Select * From Templates";
    $result = mysql_query($SQL);
    while($row = mysql_fetch_array($result))
    {
    echo (" 
       <tr> 
        <td><div class = 'style8' align = 'left'>".$row['FileName']."</div></td>
        <td><div class = 'style8' align = 'right'>".$row['TxtFldCnt']."</div></td>
        <td><div class = 'style8' align = 'left'>".$row['PhotoCnt']."</div></td>
        <td><div class = 'style8' align = 'left'>".$row['Categories']."</div></td>
        <td><div class = 'style8' align = 'right'>".$row['Enable']."</div></td>
       </tr>
       ");
    }
    ?>
    </table></td>
      <td align="center" valign="top" nowrap id = "Right_Panel">&nbsp;</td>
    </tr>
    <tr>
      <td align="center" valign="top" nowrap class="style3" id = "Left_Panel">&nbsp;</td>
      <td colspan="2" align="center" valign="top" nowrap class="style3" id = "Left_Panel">
    [COLOR="Red"]<a href = "#" id = "NewCat" name = "NewCat" onClick = "NewCat('Categories')"> New Category</a>[/COLOR]
    </td>
      <td align="center" valign="top" nowrap class="style3" id = "Left_Panel">&nbsp;</td>
      <td colspan="5" align="center" valign="top" id = "Center_Panel">&nbsp;</td>
      <td align="center" valign="top" nowrap id = "Right_Panel">&nbsp;</td>
    </tr>
    </table>
    </body>
    </html>
    Code (markup):
    http://trollnest.com/bragflags/Administration/default.php

    if you want to play please feel free!
     
    Sleeping Troll, Sep 2, 2008 IP