$("#texta").blur(function(){
var number = $("#texta").val();
$.ajax({
url:'ajax.php',
data:'number=' + val + '&rand=' + Math.random(),
success:function(data){
$("#textb").val(data)
},
error:function(){
alert('数据请求失败');
}
});
});ajax.php$number = addslashes($_GET['number']);
$thisinfo = $db->fetchone("select content from table where number = '{$number}'");
return $thisinfo['cotnent'];
我靠,分比我还多
ajax.php
$number = addslashes($_GET['number']);
$thisinfo = $db->fetchone("select content from table where number = '{$number}'");
echo $thisinfo['cotnent']; //哎呀,上面写错了
这个用JS的onkeypress转ajax即可.
如果代码位数固定可提高效率.
在JQuery里也很容易实现:
$.fn.observe = function( time, callback ){
return this.each(function(){
var form = this, change = false; $(form.elements).change(function(){
change = true;
}); setInterval(function(){
if ( change ) callback.call( form );
change = false;
}, time * 1000);
});
};