我有一个包含 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");
关于actionscript-3 - navigatorToURL post 方法的 as3 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10186494/