我正在学习PHP,我甚至不知道如何让它工作。我需要帮助编写为此JQuery返回数据的文件$.post()
我不知道如何使用firebug,但是Firefox的错误控制台显示" error : no element found“
<!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" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<title>JQuery Test</title>
</head>
<body>
<a class="open" href="#" style="color:black; text-decoration:none;">Test File</a>
<br />
<pre id="Test">Hello</pre>
<script type="text/javascript">
$('.open').click(function(){
$.post('source.php', function(src){
alert(src)
$('#Test').html(src);
});
return false;
});
</script>
</body>
</html>PHP文件
<?php
echo "hi"
?>
发布于 2011-07-23 12:17:46
测试id选择器错误,请在下面尝试
<script type="text/javascript">
$('.open').click(function(){
$.post('source.php', function(src){
alert(src)
$('#Test').html(src);
});
/*
$.post('source.php', {name: current}, function(src){
codeBox.html(src);
});
*/
return false;
});
</script>发布于 2011-07-23 12:18:55
:你的脚本中有很多缺陷。
The **$('Test').html(src);** will not work it should be **$('#Test').html(src);**
The **<?php>** should be just **<?php**https://stackoverflow.com/questions/6798179
复制相似问题