Neden responseText buna eklenir hostname ve zaman damgası var mı?

0 Cevap php

Ben temel AJAX / php testi çalışıyorum. Ben iki değer yazdığınız iki giriş metin alanları ile bir form ve bir düğmeye bastığınızda, giriş alanları üçüncü metin alanına birlikte ve çıkış birleştirilmiş, bir çıkış metin alanı var. AJAX / PHP ile yapıyorum. Ben üçüncü alana Zincirleme değer çıktı almak, ama geri PHP almak responseText için eklenen bazı ek metin gibi görünüyor. Web sunucusunun ana bilgisayar adı ve bir zaman damgası ile - eklenen metin bir HTML açıklama (<) 'dir. Bunu nasıl kurtulurum? ResponseText responseText dizesinde bu ek bilgi ile geri gelmek için bu normal mi?

Aşağıdaki gibi PHP / HTML sayfası:

<!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=utf-8" />
<title>AJAX/PHP Test</title>

</head>
<body>

<script language="javascript" type="text/javascript">
// Get the HTTP Object
function getHTTPObject(){
   if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
   else if (window.XMLHttpRequest) return new XMLHttpRequest();
   else {
      alert("Your browser does not support AJAX.");
      return null;
   }
}

// Change the value of the output field
function setOutput() {
  var val;
  val="";
  if (httpObject.readyState == 4) {
    val=httpObject.responseText;
     if ( val != undefined ) {
       document.getElementById('outputFld').value = val;
     }
  }
}

// Implement business logic
function doWork(){
   var url;
   httpObject = getHTTPObject();
   if (httpObject != null) {
      httpObject.onreadystatechange = setOutput;
      url="concat.php?inputText="+document.getElementById('inputFld1').value+"&inputText2="+document.getElementById('inputFld2').value;
      httpObject.open("GET", url, true);
      httpObject.send(null);
   }
}

var httpObject = null;

</script>
This is a test page to see how to get ajax and php to work together when submitting a form with data.

<P>

First we have a simple form.  The php will be called when the button is pressed and will concatenate
"Input 1" and "Input 2" and write the output to the "Output" field. <P><P>


</body>

<form>
   Input 1: <input type="text" id="inputFld1"  size="50" /><br>
   Input 2: <input type="text" id="inputFld2"  size="50" /><br>
<HR>
   Output: <input type="text" id="outputFld"  size="100" /><br>
<P>
   <input type="button" name="submitButton" value="Concatenate" onClick="doWork()" />


</html>

aşağıdaki gibi OPEN çağrısı (concat.php) ile URL çağrıldığını PHP:

<?php
  $in1 = $_GET['inputText'];
  $in2 = $_GET['inputText2'];
  $returnvar = $in1 . ' - ' . $in2;
  echo $returnvar;
?>

Benim iki giriş alanları "ONE" ve İKİ demek içeriyordu (geri responseText geçti alır nedir "dir:

ONE - TWO<!-- webserver1.thedomain.com compressed/chunked Thu Jul  1 15:42:08 PDT 2010 -->

Ne var "" açıklama responseText için ekli?

0 Cevap