PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Dec 10, 2018 11:38 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Sep 23, 2018 6:35 am 
Offline
Forum Commoner

Joined: Thu Aug 10, 2017 4:48 pm
Posts: 33
Hi,

I'm using a JSON request to get some data. This data will be used in a dinamic page. The doubt is after making a xmlhttp request i need the page to understand the code. I'm using

Code:
if (this.readyState == 4 && this.status == 200) {
var myObj = JSON.parse(this.responseText);

for (x in myObj.data) {

document.write(''+ myObj.data[x].url +'');
}
}


For the JSON
Code:
{"status_code":200,"status_txt":"OK","data":{"url":"http://bit.ly/2eFeMvZ","hash":"2eFeMvZ","global_hash":"2V6CFi","long_url":"http://www.google.com/","new_hash":0}}


But it isn't correct, can anyone help me or point to a good JSON tutorial

Thanks


Top
 Profile  
 
PostPosted: Mon Sep 24, 2018 11:27 pm 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13583
Location: New York, NY, US
What do you want to do with myObj.data? Do you want to write the values into HTML elements on the page?

_________________
(#10850)


Top
 Profile  
 
PostPosted: Sat Oct 06, 2018 10:34 am 
Offline
Forum Commoner

Joined: Thu Aug 10, 2017 4:48 pm
Posts: 33
I already found the solution.

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group