<?php echo 'hello';?><!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> p { width: 100px; height: 100px; border: 1px solid red; } </style> </head> <body> <p></p> <script type="text/javascript"> var op = document.getElementsByTagName('p')[0]; op.addEventListener('click', function(e) { var xml = new XMLHttpRequest(); xml.onreadystatechange = function() { if(xml.readyState === 4) { if((xml.status >= 200 && xml.status < 300) || xml.status == 304) { document.body.innerHTML+=xml.responseText; } } } xml.open('GET', '002.php', true); xml.send(); }) </script> </body></html>php echo里面的內容為啥不對???和ajax,responseText獲取的數據不一樣,為什么。。
新手學ajax遇到問題,為什么獲取不到echo里面的內容?
慕田峪9158850
2019-03-21 22:15:10