简体   繁体   中英

Get an array as answer from HTTP request on iPhone

是否可以在我的服务器上的php中生成一个数组,并且当通过HTTP请求请求时,将此数组发送到iPhone,以便我可以在iPhone中使用该数组值?

通常,您将其作为JSON或XML发送,然后在设备上使用它

You must send your array serialized into JSON for example:

<?php

    $data = array(
            'fullname' => 'Dan Jesus',
            'age' => 25
    );

    echo json_encode($data);
 ?>

To capture this JSON object you sent in your javascript is simple, you can use JSON.parse(data) or if using jQuery can use $.parseJSON(data);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM