简体   繁体   English

从服务器读取的ajax文件的w3schools.com示例在IE9中有效,但在FF12中无效

[英]The w3schools.com example for ajax file read from server works in IE9 but not FF12

I need to read the contents of a text file from the server and parse the contents with JavaScript, in order to add elements to the page depending on the contents. 我需要从服务器读取文本文件的内容,并使用JavaScript解析内容,以便根据内容向页面添加元素。

But, the example at W3Schools works great in FF12 but if I copy the source from the left-pane of the example to an .html file, and create the required data file "demo_ajax_load.txt" in the same directory as my .html, it doesn't work. 但是, W3Schools的示例在FF12中效果很好,但是如果我将示例左侧的源代码复制到.html文件,并在与.html相同的目录中创建所需的数据文件“ demo_ajax_load.txt”,它不起作用。 However, it works okay in IE9. 但是,它在IE9中可以正常工作。

Here's the source: 来源:

<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("button").click(function(){
    $.get("demo_ajax_load.txt", function(result){
      $("div").html(result);
    });
  });
});
</script>
</head>
<body>

<div><h2>Let AJAX change this text</h2></div>
<button>Change Content</button>

</body>
</html>

使用vxworks而不是Windows解决了该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM