【问题标题】:specifying the "request method" in externalinterface.call method?在 externalinterface.call 方法中指定“请求方法”?
【发布时间】:2013-09-30 10:10:31
【问题描述】:

当用户尝试下载文件时,我需要打开一个新的 html 窗口并下载文件,目前我正在使用“ExternalInterface.call”但我需要设置“requestmethod”否则服务器会抛出错误,如何指定“请求方法”?

【问题讨论】:

  • ExternalInterface.call可以调用JS函数,所以获取JS函数设置请求方法和URL
  • 我可以设置URL,如何在JavaScript中设置请求方法
  • 这超出了我的专业领域

标签: actionscript-3 apache-flex adobe


【解决方案1】:

为什么不使用全局navigateToURL 方法?你可以传入一个URLRequest 对象,它有一个名为method 的属性,它将解决你的问题。

所以你需要这样的东西:

var request:URLRequest = new URLRequest("http://example.com");
request.method = URLRequestMethod.POST; // or anything you want

// parameters can be added to a URLVariables object 
// which then can be set as requests data property
// example:

var params:URLVariables = new URLVariables();
params.username = "test";
params.password = "123";

request.data = params;

// load the page
// specify '_blank' parameter to open it in a new browser window
navigateToURL(request, "_blank");

【讨论】:

  • navigateToURL 与 chrome 29 有一些问题。这就是我们正在寻找其他解决方案的原因。
  • 然后按照@Lee Burrows 的建议进行操作。
猜你喜欢
  • 1970-01-01
  • 2018-05-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-11
  • 2017-02-01
  • 2014-07-02
相关资源
最近更新 更多