简体   繁体   中英

Read JSON Format

I've created a line of code that function to read data from SOAP service. But I have a little problem. I'm using JSONP Lib in this task but has not produced results. I tried the same with less code to read the output of a database query and the results were successful. Is there a difference between these two methods? The first one I made ​​the PHP code to transfer the array into the form of json :

<?php
error_reporting(0);
header('content-type:application/json;charset=UTF-8');
date_default_timezone_set("Asia/Jakarta");
require_once('lib/nusoap.php');

$Param1 = "bertho_joris@yahoo.co.id";
$Param2 = "12345";

$client = new nusoap_client('http://vcare.telkomvision.net.id/services/VcareServices.php');
$ReadSOAP = $client->call('validateLogin', array('EMAIL' => $Param1, 'PASSWORD' => md5($Param2)));

echo '{"items":['. json_encode($ReadSOAP) .']}';
?>

And the data produced by the above code is :

{
"items": [
    {
        "NE": "42616324457",
        "EMAIL": "bertho_joris@yahoo.co.id",
        "TIPE": "POSTPAID",
        "NAMA": "ALBERTHO MALAQUENA JORIS/NPK:120488047",
        "TELP": "081310117966 / 087878837451",
        "DN": "127225148174",
        "STATUS_LOGIN": "1",
        "DESC_LOGIN": "Valid"
      }
   ]
}

I use the library below to process the output data to be read later in my application : JSONP Library

JSONP.get( 'MyURL.php', {Email:'MyEmail', Password:'MyPass'}, function(data){
    for ( var i = 0; i < response.length; ++i ) {
          str = response[i].ne;
          str2 = response[i].email;
          str3 = response[i].tipe;
          str4 = response[i].nama;
          str5 = response[i].telp;
          str6 = response[i].dn;
          str7 = response[i].desc_login;
    }
});

But the result I get is : My application can not read data output directly from the SOAP above . I am confused why be like that. And I think JSON format is correct.

Then I tried to read the data directly from the database. This database is a sample, and I accidentally made ​​the same data with the output of the SOAP reading process above.

And the result, I successfully get the data.

I include two links that I use to do the reading.

  1. This link is the php file that processes the SOAP directly from the server and the output is JSON : Failed to Reading

  2. This is the direct link to the database with a dummy database. JSON output. And I succeed using this second method : Success to Reading

Please help me resolve my problem was. The point I want to read the data directly from the process using the SOAP form that outputs JSON. as I have described as a failure.

Thank you

Try this:

JSONP.get( 'MyURL.php', {Email:'MyEmail', Password:'MyPass'}, function(data){
    for (var i = 0; i < response.length; i++) 
    {
        str  = response[i].NE;
        str2 = response[i].EMAIL;
        str3 = response[i].TIPE;
        str4 = response[i].NAMA;
        str5 = response[i].TELP;
        str6 = response[i].DN;
        str7 = response[i].DESC_LOGIN;
    }
 });

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