Home  >  Article  >  Backend Development  >  从php中传值给JS,却传回了一个奇怪的值?解决思路

从php中传值给JS,却传回了一个奇怪的值?解决思路

WBOY
WBOYOriginal
2016-06-13 10:07:44852browse

从php中传值给JS,却传回了一个奇怪的值?
我要从a.php中传一个0给b.js 可是传来的是一大串!原代码如下:


a.php文件:

echo "0";

?>


b.js文件:

function get_C()
{
  if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
  var c = xmlHttp.responseText;
  alert(c);
 } 
}

对话框输出的结果却是如下一大堆字符:




无标题文档





0

怎么回事?能把前面的一大堆去掉吗?




------解决方案--------------------
a 输出 json
b 读取 json alert
------解决方案--------------------
前面那一大段html是哪来的?你单独执行a.php后查看源代码看看。看是不是有html代码。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn