如何通过Jquery.post发布JSON多维数据? [英] How can I post a JSON multi-dimensional data via Jquery.post?

查看:52
本文介绍了如何通过Jquery.post发布JSON多维数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过$ .post发布JSON多维数据?例如,我有一个JSON格式的多维数组:

How can I post a JSON multi-dimensional data via $.post? For instance, I have this multi-dimensional array in JSON format:

{
    "file":
    {
       "name" : "1024x768.jpg",
       "type" : "image\/jpeg",
       "tmp_name" : "C:\\wamp\\tmp\\php8F59.tmp",
       "error":0,"size":469159
    }
}

我将使用Jquery.post()发布JSON数据.

I will use Jquery.post() to post the JSON data.

$.post("process.php",'{"name":"1024x768.jpg","type":"image\/jpeg","tmp_name":"C:\\wamp\\tmp\\php8F59.tmp","error":0,"size":469159}}',function(xml){

});

所以我可以使用print_r($_POST)process.php中获得此数组:

So I can get this array in process.php using print_r($_POST):

Array
(
    [file] => Array
        (
            [name] => 1024x768.jpg
            [type] => image/jpeg
            [tmp_name] => C:\wamp\tmp\phpA1.tmp
            [error] => 0
            [size] => 469159
        )
)

这可能吗?

推荐答案

尝试一下:

$.post("process.php",{"file":{"name":"1024x768.jpg","type":"image\/jpeg","tmp_name":"C:\\wamp\\tmp\\php8F59.tmp","error":0,"size":469159}},function(xml){

});

应该在php端为您提供所需的数组

that should give you the desired array on the php side

自jQuery 1.4及更高版本开始有效

this works since jQuery 1.4 and above

这篇关于如何通过Jquery.post发布JSON多维数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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