actionscript-3 - navigatorToURL post 方法的 as3 问题

标签 actionscript-3 http-post

我有一个包含 Flash 对象的页面。在特定操作中,页面需要重定向到其他页面并发送一些数据(变量)。我结合使用 urlvariables 和 navigatorToURL 来执行此操作。页面重定向并发送数据(变量)。

但问题是数据(变量)是在查询字符串中发送的(我的意思是这样的“http://dummy.php/?first_name=xyz”)。我正在使用 post 方法发送数据(变量)。我无法像查询字符串一样发送数据(变量)。

如何解决这个问题?

PS:我已经在下面编写了所有代码...

var request:URLRequest = new URLRequest("http://dummy.php");
var vars:URLVariables = new URLVariables();
vars.first_name = 'xyz';
request.data = vars;
request.method = URLRequestMethod.POST;
navigateToURL(request, "_blank");

最佳答案

我刚刚做了这个简单的测试,向 Twitter 的搜索 API 发送 POST 请求(它似乎同时接受 GET 和 POST 请求)。正如您在所附屏幕截图中看到的,浏览器的 URL 字段没有显示任何变量,而 Httpfox(您可以使用 Firebug、Chrome 的开发人员工具等执行相同的操作)显示按预期通过 POST 传递的变量。您发布的示例代码是给您带来麻烦的真正代码吗?这是我使用的:

    // Create the POST request
var request:URLRequest = new URLRequest("http://search.twitter.com/search.json");
request.method = URLRequestMethod.POST;

// Create the variables object
var vars:URLVariables = new URLVariables();
vars.q = 'love';
vars.rpp = '5';
vars.include_entities = 'true';

// Attach variables to request object
request.data = vars;

// Open new window using the POST request
navigateToURL(request, "_blank");

Httpfox screenshot showing POST vars being passed as expected

关于actionscript-3 - navigatorToURL post 方法的 as3 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10186494/

相关文章:

actionscript-3 - socket.readBytes 不移动指针

https - HTTP : Why is wrong sending username and password in get request?

javascript - JQuery-Select2 - 操作发送的 http-post 数据以发送文本而不是 ID

ios - 编写 iOS http Post 类

javascript - 有没有比 PNGEncoder 更快的将位图数据编码为 PNG 的方法?

iphone - JPEG编码器速度超慢,如何优化?

ios - 闪存 AS3 AIR 3.0 iOS : Timer optimization?

Flash/AIR AS3 : comparing contents of Screen. 屏幕

objective-c - 在 Objective C 中通过 POST 上传图片

android - 在 android 4.0.3 中将消息发布到 facebook 墙时出错