ajax方法:1.html =============================================================== <script language='javascript'> function getXMLHttpRequest(){ var xmlHttp;
if(window.ActiveXObject){ try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e){ try{ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ xmlHttp = false ; } } } else if(window.XMLHttpRequest) xmlHttp = new XMLHttpRequest(); return xmlHttp; }function sendRequest(){ var xmlHttp = getXMLHttpRequest(); var name = document.getElementById('name').value; var url = '2.php'; if (!xmlHttp){ return false; }
我的问题是,主题是今天网页,用户已经访问了,已经在阅读了。我只需要一个脚本,调用我网站的数据库,并输出到现有的今天网页上,把敏感数据改一下。就像有些今天网页,却显示某某已经登录什么的。
$text="数据";
echo 'document.writeln(\''.$text.'\');'?>或者用ajax 去调用一个php处理页面,然后返回到 静态的dom 节点中
至于说的“或者用ajax 去调用一个php处理页面,然后返回到 静态的dom 节点中”就弄不明白了。下次再请教。初次来到,想不到这里的人气这么旺!!!
===============================================================
<script language='javascript'>
function getXMLHttpRequest(){
var xmlHttp;
if(window.ActiveXObject){
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
try{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
xmlHttp = false ;
}
}
}
else if(window.XMLHttpRequest)
xmlHttp = new XMLHttpRequest();
return xmlHttp;
}function sendRequest(){
var xmlHttp = getXMLHttpRequest();
var name = document.getElementById('name').value;
var url = '2.php'; if (!xmlHttp){
return false;
}
xmlHttp.onreadystatechange = function() {
if(xmlHttp.readyState < 4)
document.getElementById('status').innerHTML = 'waiting...';
if(xmlHttp.readyState == 4){
if (xmlHttp.status == 200){
response = xmlHttp.responseText;
document.getElementById('status').innerHTML = 'price:<font color=red>'+unescape(response)+'</font>';
}
else
{
document.getElementById('status').innerHTML = 'error!';
}
}
}
xmlHttp.open('POST',url,true);
xmlHttp.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded;charset=gbk");
xmlHttp.send('name='+escape(name));
}document.onkeypress = function(){
if(window.event.keyCode == 13)
sendRequest();
}
</script>
name(Apple or Pear or Orange):<input type="text" id="name" value=""/>
<div id="status" >price:</div>
==============================================================================2.php
==============================================================================
<?php
$name = $_POST["name"];
$price=array(
"Apple" => 1.5,
"Pear" => 2.5,
"Orange" => 1,4
);
echo $price[$name];
?>
==============================================================================
$text="数据";
echo 'document.writeln(\''.$text.'\');'?>能不能写具体点了,最好给个完整例子
$text="数据";
echo 'document.writeln(\''.$text.'\');'?>能不能写具体点了,最好给个完整例子
$text="数据";
echo 'document.writeln(\''.$text.'\');'?>给个具体例子吧