Javascript ';未定义函数';脚本w/jQuery中出现错误

Javascript ';未定义函数';脚本w/jQuery中出现错误,javascript,jquery,function,Javascript,Jquery,Function,我得到一个“未定义函数”Javascript错误,代码如下,使用jQuery: <!DOCTYPE html> <html> <head> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> <script type="text/javascrip

我得到一个“未定义函数”Javascript错误,代码如下,使用jQuery:

<!DOCTYPE html>  
<html>  

<head>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>

<script type="text/javascript">

function log_in() {
   document.write('Logging in ... ');
   $.post('process_ajax.php', { 'action' : 'log in' }, function(data) {
      document.write(data);
      create_new_story();
   });
}

function create_new_story() {
   document.write('Creating new story ... ');
   $.post('process_ajax.php', { 'action' : 'create story' }, function(data) {
     document.write(data);
   });
}

</script>

</head>

<body onload="log_in()">
Processing...<br>
</body>

</html>

函数log_in(){
document.write('登录…');
$.post('process_ajax.php',{'action':'login'},函数(数据){
文件。写入(数据);
创建新的故事();
});
}
函数create_new_story(){
写(‘创建新故事…’);
$.post('process_ajax.php',{'action':'create story'},函数(数据){
文件。写入(数据);
});
}
正在处理…
以下是它调用的PHP脚本(用于测试目的):


第一个名为--log_in()--的函数工作正常,但我遇到以下错误:

“错误:未定义创建新故事”

这个函数永远不会被执行


我肯定我错过了一些简单的东西。我可以找一双新眼睛来找到它吗?

你只能调用
文档。在页面仍在加载时编写

您不能稍后调用它,否则它将吹走现有页面


相反,您应该使用jQuery的
.append
方法。

您只能在页面仍在加载时调用
文档。编写

您不能稍后调用它,否则它将吹走现有页面


相反,您应该使用jQuery的
.append
方法。

当您调用document.write()时,DOM准备就绪后,它实际上会用document.write()的参数替换整个页面


请参阅。

在DOM就绪后调用document.write()时,它实际上会用document.write()的参数替换整个页面

<?

die("Page opened.<br>");

?>