在 Webstorm IDE 中读取本地 xml 文件。(+ node.js, ajax)
Reading a local xml file in Webstorm IDE.(+ node.js, ajax)
我现在正在使用最新的 Webstorm IDE 来开发 Ajax 的网页。
1.
要读取本地 xml 文件,我启动服务器并使用 chrome 访问本地主机,但我没有读取本地 xml 文件。
2.
要读取本地 xml 文件,我使用下图中的 Webstorm 函数。
最后,我成功读取了本地 xml 文件。
- "number1 method" 和 "number2 method" 有什么区别?
提前致谢!!
============================================= =============================
<script type="text/javascript">
$(function () {
$('#resourceName').click(function() {
$.ajax({
url: "ResourceFormat/xml/test.xml",
type: "get",
dataType: "text",
cache: false,
timeout: 30000,
success: function(data) {
$('#bodyText').val(data);
},
error: function(xhr, textStatus, errorThrown) {
alert(textStatus + ': ' + xhr);
}
});
});
});
</script>
由于同源政策,您可以参考以下链接:
- https://developer.mozilla.org/en-US/docs/Same-origin_policy_for_file:_URIs
- Can't load a file in ajax from my pc
我现在正在使用最新的 Webstorm IDE 来开发 Ajax 的网页。
1. 要读取本地 xml 文件,我启动服务器并使用 chrome 访问本地主机,但我没有读取本地 xml 文件。
2. 要读取本地 xml 文件,我使用下图中的 Webstorm 函数。
最后,我成功读取了本地 xml 文件。
- "number1 method" 和 "number2 method" 有什么区别?
提前致谢!!
============================================= =============================
<script type="text/javascript">
$(function () {
$('#resourceName').click(function() {
$.ajax({
url: "ResourceFormat/xml/test.xml",
type: "get",
dataType: "text",
cache: false,
timeout: 30000,
success: function(data) {
$('#bodyText').val(data);
},
error: function(xhr, textStatus, errorThrown) {
alert(textStatus + ': ' + xhr);
}
});
});
});
</script>
由于同源政策,您可以参考以下链接:
- https://developer.mozilla.org/en-US/docs/Same-origin_policy_for_file:_URIs
- Can't load a file in ajax from my pc