在java脚本中获取文件内容 [英] Get file contents in java script
本文介绍了在java脚本中获取文件内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个URL,其内容也是JavaScript代码,我希望通过JavaScript获取此URL的内容,例如PHP和show中的 file_get_contents()
它们使用 alert()
函数给用户。
I've a URL that its contents are also JavaScript codes, I want to get the contents of this URL via JavaScript something like to file_get_contents()
in PHP and show them to the user using the alert()
function.
推荐答案
你可以在Javascript中使用XMLHttpRequest从外部URL获取数据。这是一个很好的资源: http://www.w3schools.com/ajax/default.asp(我通常不推荐它们,但是AJAX教程非常好)。
You can use XMLHttpRequest in Javascript to fetch datas from an external URL. Here is a good resource : http://www.w3schools.com/ajax/default.asp (I usually don't recommend them, but the AJAX tutorial is really good).
此外,这必须在那里:
这篇关于在java脚本中获取文件内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文