title: php code as converted in asp.net not working as expected?
body: <p>Doing example of <code>Ajax</code>, a user type in textbox and its text is continuously posted back using javascript and simultanously showing result whether the item available or not.</p>
  
  <p>main <strong>html</strong> look is as</p>
  
  <pre><code> &lt;body&gt;
              &lt;h3&gt;The chuff Bucket &lt;/h3&gt;
              Enter the food you like to order:
              &lt;input type="text" id="userInput" onfocus="process()"/&gt;
              &lt;div id="underInput"/&gt;
   &lt;/body&gt;
  </code></pre>
  
  <p>Here is my code for javascript</p>
  
  <pre><code>var xmlHttp = createXmlHttpRequestObject();    
  
  function createXmlHttpRequestObject() {
      var xmlHttp;
  
      if (window.ActiveXObject) {
          try {
              xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
          }
          catch (e) {
              xmlHttp = false;
          }
      } else {
          try {
              xmlHttp = new XMLHttpRequest();
          }
          catch (e) {
              xmlHttp = false;
          }
      }
  
      if (!xmlHttp) {
          alert("cant create that object boss!");
      } else
          return xmlHttp;
  
  }
  
  
  function process() {
      if (xmlHttp.readyState == 0 || xmlHttp.readyState == 4) {
          food = encodeURIComponent(document.getElementById("userInput").value);
          xmlHttp.open("GET", "foodstore.aspx?food=" + food, true);
  
          xmlHttp.onreadystatechange = handleServerResponse;
          xmlHttp.send(null);
  
      } else {
          setTimeout('process()', 1000);
      }
  }
  
  function handleServerResponse() {
      if (xmlHttp.readyState == 4) {
          if (xmlHttp.status == 200) {
              xmlResponse = xmlHttp.responseXML;
              xmlDocumentElement = xmlResponse.documentElement;
              message = xmlDocumentElement.firstChild.data;
  
              document.getElementById("underInput").innerHTML = '&lt;span style = "color:blue;"&gt;' + message + '&lt;/span&gt;';
              setTimeout('process()', 1000);
          } else {
              alert('Something went wrong');
          }
      }
  }
  </code></pre>
  
  <p>The code for php is working fine which is</p>
  
  <pre><code>&lt;?php
  
  header('Content-Type: text/xml');
  echo '&lt;?xml version="1.0" encoding="UTF-8" standalone="yes" ?&gt;';
  
  echo '&lt;response&gt;';
       $food = $_GET['food'];
       $foodArray = array("tuna","bacon","beef","mutton","biryani");
  
       if($food == '')
           echo 'Enter a food you idiot.';
       else{
           if(in_array($food,$foodArray))
            echo 'We do have '.$food.'!';
           else
            echo 'We do not sell '.$food.'!';
       }
  echo '&lt;/response&gt;';
  ?&gt;
  </code></pre>
  
  <p>But when converted to asp.net it is postback and and working but not showing the reult inside the div. Main cause which i figure out relating echo lines</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
          {
              Response.ContentType = "text/xml";
              System.Diagnostics.Debug.Print("&lt;?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?&gt;");
              System.Diagnostics.Debug.Print("&lt;response&gt;");
              string food = (string)Request.QueryString["food"];
  
              string[] foodArray = new string[] { "tuna", "beef", "mutton", "fish","biryani" };
  
              if (String.IsNullOrEmpty(food))
              {
                  System.Diagnostics.Debug.Print("Enter a food you idiot.");
              }
              else 
              {
                  if (foodArray.Contains(food))
                  {
                      System.Diagnostics.Debug.Print("We serve " + food);
                  }
                  else 
                  {
                      System.Diagnostics.Debug.Print("We do not serve " + food);
                  }
              }
  
              System.Diagnostics.Debug.Print("&lt;/response&gt;");
  
          }
  </code></pre>
  
  <p><strong>Note:</strong> i have tried instead of <code>Print</code> <code>Response.Write</code> but the result is same the div with id=underInput not getting the result. Anyone here help please.   </p>