AS3 AIR的URLLoader POST [英] AS3 AIR URLLoader POST

查看:408
本文介绍了AS3 AIR的URLLoader POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发展我的第一个AIR应用程序(从PHP / Javascript的移过)和我在一个阶段,我想从应用程序发送回一些数据到PHP脚本我的服务器上。我有以下几点:

I am developing my first AIR app (moving over from PHP/Javascript) and am at a stage where I want to send some data from the app back to a PHP script on my server. I have the following:

var url:String = "PHP URL HERE";
var request:URLRequest = new URLRequest(url);

var requestVars:URLVariables = new URLVariables();
requestVars.test = "1234";

request.data = requestVars;
request.method = URLRequestMethod.POST;
request.contentType = "application/xml;charset=utf-8";

var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.TEXT;
urlLoader.addEventListener(Event.COMPLETE, processSERPS, false, 0, true);
urlLoader.load(request);

我也有在服务器端的PHP脚本别的东西,但最初调试我只是改变了它转储请求阵列。

I did have something else in the server side PHP script originally but for debugging I just changed it to dump the REQUEST array.

随着code以上就简单返回nothing:

With the code above it will simply return nothing:

Array
(
)

但是,如果我改变请求方法获取:

But if I change the request method to Get:

request.method = URLRequestMethod.GET;

我收到了:

Array
(
    [test] => 1234
)

它告诉我,code是正确的,它只是不发送参数后因某种原因。

Which tells me that the code is correct, it just isn't sending the post parameters for some reason.

我只想改变code使用GET变量,但不幸的是我需要发送的数据太大,因此需要进行自检。

I would just alter the code to use GET variables but unfortunately the data I need to send is too large hence the need for POST.

任何帮助AP preciated!

Any help appreciated!

推荐答案

有关<一href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLRequest.html#contentType"相对=nofollow> URLRequest.contentType :

如果data属性的值是一个URLVariables对象,值   的contentType必须是应用程序/ x-WWW的形式urlen codeD。

If the value of the data property is a URLVariables object, the value of contentType must be application/x-www-form-urlencoded.

这是默认值,所以就删除你的任务应该这样做。

This is the default value, so just removing your assignment should do it.

这篇关于AS3 AIR的URLLoader POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆