sidney1979 发表于 2010-2-20 11:55:07

jquery的Ajax调用在IIS服务器上可以调用,在Apache服务上无法调用

demo1.html

<!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>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
* { margin:0; padding:0;}
body { font-size:12px;}
.comment { margin-top:10px; padding:10px; border:1px solid #ccc;background:#DDD;}
.comment h6 { font-weight:700; font-size:14px;}
.para { margin-top:5px; text-indent:2em;background:#DDD;}
</style>
<!--   引入jQuery -->
<script src="jquery-1.4.min.js" type="text/javascript"/>
<script type="text/javascript">
//<![CDATA[
   $(function(){
      $('#send').click(function() {
            $.ajax({
                          type: "GET",
                          url: "test.js",
                          dataType: "script"
                        });
      });
   })
//]]>
</script>
</head>
<body>
<br/>
<p>
       <input type="button" id="send" value="加载"/>
</p>

<divclass="comment">已有评论:</div>
<div id="resText" >
       
</div>

</body>
</html>

test.js

var comments = [
{
    "username": "张三",
    "content": "沙发."
},
{
    "username": "李四",
    "content": "板凳."
},
{
    "username": "王五",
    "content": "地板."
}
];

var html = '';
$.each( comments , function(commentIndex, comment) {
      html += '<div class="comment"><h6>' + comment['username'] + ':</h6><p class="para">' + comment['content'] + '</p></div>';
})

$('#resText').html(html);



在iis服务器上运行正常,在Apache 2.2.11服务器上无法运行,apache需要做什么配置么?

jeongee 发表于 2010-2-20 14:20:44

看返回什么错误啊

sidney1979 发表于 2010-2-22 16:24:51

ok了 jquery的文件路径错了 :dizzy:
页: [1]
查看完整版本: jquery的Ajax调用在IIS服务器上可以调用,在Apache服务上无法调用