Actionscript 3 as3中的JSON编码

Actionscript 3 as3中的JSON编码,actionscript-3,json,Actionscript 3,Json,我有一段代码,我用它将JSON编码格式的数据传递给php。有没有办法在php端检查它是否以正确的格式接收和发送 var people:Array = new Array(); var person:Object = new Object(); var url:String = "http://localhost/ping.php"; var request:URLRequest = new URLRequest(url); var requestVars:URLV

我有一段代码,我用它将JSON编码格式的数据传递给php。有没有办法在php端检查它是否以正确的格式接收和发送

var people:Array = new Array();
    var person:Object = new Object();
    var url:String = "http://localhost/ping.php";
    var request:URLRequest = new URLRequest(url);
    var requestVars:URLVariables = new URLVariables();
    var loader:URLLoader = new URLLoader();
    person.fullname = "jon jay junior";
    person.username = "jjj";
    person.role = "ADMIN";
    people.push(person);
    request.method = URLRequestMethod.POST;
    requestVars.myObject = JSON.encode(people);
    request.data = requestVars;
    loader.load(request);

检查
$\u POST['data']
$\u REQUEST['data']
是否已设置且不为空。

检查
$\u POST['data']
$\u REQUEST['data']
是否已设置且不为空。

您可以将响应记录到文件(
print\r($\u POST)
),或类似的数据库,但是,如果您正在调试代码,最简单的方法是使用firebug、httpfox(两者都适用于firefox)或其他工具来查看http请求和响应。然后,您可以准确地看到您发送给php脚本的内容。

您可以将响应记录到文件(
print\r($\u POST)
)、数据库或类似的地方,但如果您正在调试代码,最简单的方法是使用firebug、httpfox(都适用于firefox)或其他一些工具,让您可以查看http请求和响应。然后您可以确切地看到您发送给php脚本的内容。

正如其他人所提到的,您应该使用Firebug、LiveHTTPHeaders或类似的工具(Firefox有几种)查看请求。这将让您看到数据的格式

如果在PHP中,
$\u请求['myObject']
确实是
null
,那么一定是出了问题。您应该真正附加一个
loader.addEventListener(IOErrorEvent.IO_ERROR,handleIOError)
检查问题和/或使用调试Flash player运行,以便您可以看到正在发生的任何异常


如果您在浏览器中运行此功能,调试技巧是通过
ExternalInterface.call()

调用Firebug的
控制台.log
,正如其他人所提到的,您应该使用Firebug、LiveHTTPHeaders或类似工具查看请求(Firefox有几种)。这将让您看到数据的格式

如果在PHP中,
$\u请求['myObject']
确实是
null
,那么一定是出了问题。您应该真正附加一个
loader.addEventListener(IOErrorEvent.IO_ERROR,handleIOError)
检查问题和/或使用调试Flash player运行,以便您可以看到正在发生的任何异常

如果您在浏览器中运行此功能,调试技巧是通过
ExternalInterface.call()

调用Firebug的
控制台.log