【问题标题】:Amber Smalltalk and XMLHttpRequest (GET)Amber Smalltalk 和 XMLHttpRequest (GET)
【发布时间】:2013-08-28 02:11:03
【问题描述】:

我尝试打印

| req |
req := XMLHttpRequest new.
req open: 'GET' url: 'http://www.stackoverflow.com/' asynchronous: false.
req send: ''.
req responseText

调试器告诉我

[Exception... "Failure" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location:
"JS frame ::   http://amber-lang.net/amber/js/boot.js :: callJavaScriptMethod ::
 line 651" data: no]

这发生在http://amber-lang.net/ 上当前琥珀色 IDE 的工作区中

注意事项:

我已经翻译了 JavaScript 消息

req.open("GET", url, false); 

根据http://amber-lang.net/documentation.html#JSObjectProxy注明的消息转换规则

SLaks 回答后更新

以下代码sn-p

| req |
req := XMLHttpRequest new.
req open: 'GET' url: 'http://amber-lang.net/' asynchronous: false.
req send: ''.
req responseText 

在从http://amber-lang.net 打开的 IDE 中执行时确实有效。

答案是

'<!DOCTYPE html>
<html>
  <head>
    <title>Amber Smalltalk</title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="author" content="Nicolas Petton" />

 ....

【问题讨论】:

    标签: xmlhttprequest http-get amber-smalltalk


    【解决方案1】:

    出于安全原因,您不能使用 AJAX 从其他域读取数据。
    (除非它明确允许你)

    这被称为Same-origin policy

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-13
      • 1970-01-01
      • 1970-01-01
      • 2014-05-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多