Fixing AJAX: XMLHttpRequest

  Livid's Paranoid - nerd's substance - Fixing AJAX: XMLHttpRequest   
Fixing AJAX: XMLHttpRequest
http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-harmful.html

AJAX applications wouldn't be possible (or, at least, wouldn't be nearly as cool) without the XMLHttpRequest object that lets your JavaScript application make GET, POST, and other types of HTTP requests from within the confines of a web browser. All of the most interesting AJAX applications that have appeared in the past couple of years use the XMLHttpRequest object extensively to give users a responsive in-browser experience without the messiness of traditional HTML forms posting.

But the kind of AJAX examples that you don't see very often (are there any?) are ones that access third-party web services, such as those from Amazon, Yahoo, Google, and eBay. That's because all the newest web browsers impose a significant security restriction on the use of XMLHttpRequest. That restriction is that you aren't allowed to make XMLHttpRequests to any server except the server where your web page came from. So, if your AJAX application is in the page http://www.yourserver.com/junk.html, then any XMLHttpRequest that comes from that page can only make a request to a web service using the domain www.yourserver.com. Too bad -- your application is on www.yourserver.com, but their web service is on webservices.amazon.com (for Amazon). The XMLHttpRequest will either fail or pop up warnings, depending on the browser you're using.

On Microsoft's IE 5 and 6, such requests are possible provided your browser security settings are low enough (though most users will still see a security warning that they have to accept before the request will proceed). On Firefox, Netscape, Safari, and the latest versions of Opera, the requests are denied. On Firefox, Netscape, and other Mozilla browsers, you can get your XMLHttpRequest to work by digitally signing your script, but the digital signature isn't compatible with IE, Safari, or other web browsers.

Solutions Worthy of Paranoia

There is hope, or rather, there are gruesome hacks, that can bring the splendor of seamless cross-browser XMLHttpRequests to your developer palette. The three methods currently in vogue are:
  1. Application proxies. Write an application in your favorite programming language that sits on your server, responds to XMLHttpRequests from users, makes the web service call, and sends the data back to users.
  2. Apache proxy. Adjust your Apache web server configuration so that XMLHttpRequests can be invisibly re-routed from your server to the target web service domain.
  3. Script tag hack with application proxy (doesn't use XMLHttpRequest at all). Use the HTML script tag to make a request to an application proxy (see #1 above) that returns your data wrapped in JavaScript. This approach is also known as On-Demand JavaScript.
The basic idea of all three hacks is the same: fool your user's web browser into thinking that the data is coming from the same domain as the web page.

A word of caution here: there is a good reason why XMLHttpRequests are restricted. Allowing them to freely access any domain from within a web page opens up users to potential security exploitation. Not surprisingly, these three hacks, which offload the request to your web server, potentially threaten to disparage your web server's identity, if not its contents. Caution is advised before deploying them.
http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-harmful.html

AJAX applications wouldn't be possible (or, at least, wouldn't be nearly as cool) without the XMLHttpRequest object that lets your JavaScript application make GET, POST, and other types of HTTP requests from within the confines of a web browser. All of the most interesting AJAX applications that have appeared in the past couple of years use the XMLHttpRequest object extensively to give users a responsive in-browser experience without the messiness of traditional HTML forms posting.

But the kind of AJAX examples that you don't see very often (are there any?) are ones that access third-party web services, such as those from Amazon, Yahoo, Google, and eBay. That's because all the newest web browsers impose a significant security restriction on the use of XMLHttpRequest. That restriction is that you aren't allowed to make XMLHttpRequests to any server except the server where your web page came from. So, if your AJAX application is in the page http://www.yourserver.com/junk.html, then any XMLHttpRequest that comes from that page can only make a request to a web service using the domain www.yourserver.com. Too bad -- your application is on www.yourserver.com, but their web service is on webservices.amazon.com (for Amazon). The XMLHttpRequest will either fail or pop up warnings, depending on the browser you're using.

On Microsoft's IE 5 and 6, such requests are possible provided your browser security settings are low enough (though most users will still see a security warning that they have to accept before the request will proceed). On Firefox, Netscape, Safari, and the latest versions of Opera, the requests are denied. On Firefox, Netscape, and other Mozilla browsers, you can get your XMLHttpRequest to work by digitally signing your script, but the digital signature isn't compatible with IE, Safari, or other web browsers.

Solutions Worthy of Paranoia

There is hope, or rather, there are gruesome hacks, that can bring the splendor of seamless cross-browser XMLHttpRequests to your developer palette. The three methods currently in vogue are:
  1. Application proxies. Write an application in your favorite programming language that sits on your server, responds to XMLHttpRequests from users, makes the web service call, and sends the data back to users.
  2. Apache proxy. Adjust your Apache web server configuration so that XMLHttpRequests can be invisibly re-routed from your server to the target web service domain.
  3. Script tag hack with application proxy (doesn't use XMLHttpRequest at all). Use the HTML script tag to make a request to an application proxy (see #1 above) that returns your data wrapped in JavaScript. This approach is also known as On-Demand JavaScript.
The basic idea of all three hacks is the same: fool your user's web browser into thinking that the data is coming from the same domain as the web page.

A word of caution here: there is a good reason why XMLHttpRequests are restricted. Allowing them to freely access any domain from within a web page opens up users to potential security exploitation. Not surprisingly, these three hacks, which offload the request to your web server, potentially threaten to disparage your web server's identity, if not its contents. Caution is advised before deploying them.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 这个消息通常表示你的电脑正在尝试修复D盘上的错误或问题。可能是因为D盘上的文件系统损坏或存在其他类型的硬件问题。通常情况下,修复过程可能需要一段时间才能完成,具体时间取决于问题的严重程度和电脑的性能。建议耐心等待修复过程完成,如果问题持续存在,可以考虑联系专业技术人员进行更深入的故障排除。 ### 回答2: 当我们打开电脑时,有时候会出现黑屏提示“Fixing (D:) Stage 1”的警告信息。这是由于计算机在启动时自检修复硬盘中的错误所产生的提示。下面我们来详细解释一下这个问题。 首先,这个问题是由于硬盘分区出现问题所造成的。当系统开机检测到硬盘分区有错误时,便会进行修复。在修复的过程中,系统会对硬盘进行分区扫描并进行修复。因为修复过程是分阶段进行的,因此会显示“Fixing(D:) Stage 1”的提示信息。 那么,我们如何解决这个问题呢?首先,我们需要重启计算机并进入计算机的自动修复程序。方法是:按下F8或F11键,进入安全模式并选择启动修复程序。随后,系统会自动开启硬盘修复过程,修复分区中的错误。如果修复完成后还是出现了“Fixing (D:) Stage 1”的提示,那么我们需要进一步检查硬盘的分区。可以使用系统自带磁盘扫描器进行检查,并进行修复。 最后,我们提醒广大用户,在使用电脑时要注意保护好硬盘。避免病毒攻击以及缓存文件的无限增长等问题,定期对硬盘进行清理和优化,以保证电脑的平稳运行。 ### 回答3: 当电脑启动时出现“fixing (d:)stage1”的提示是因为系统检测到硬盘上的分区出现了一些问题,需要对其进行修复。具体来说,这个提示是在进行硬盘扫描和修复时显示的第一阶段。 在出现这个提示后,你可以等待系统完成修复操作。通常情况下,这个修复过程可能需要一些时间,具体时间取决于你的硬盘大小、文件数量和操作系统版本等因素。在整个修复过程中,你不应该关闭电脑或者中断操作,否则可能会导致数据丢失、操作系统损坏等问题。 如果修复完成后,你发现硬盘上的数据仍然无法正常访问,可以尝试使用第三方工具进行恢复。不过在使用恢复工具之前,你需要向厂商咨询并确认操作方法,否则可能会导致更多的问题。 此外,为了避免出现这种情况,你应该定期对硬盘进行数据备份,并定期进行磁盘扫描和清理,以确保硬盘的健康状态。另外,你应该选择品质可靠的硬盘,以确保其可靠性和使用寿命。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值