Solved

Parse JSON with PHP and read with jQuery

Posted on 2011-09-15
2
301 Views
Last Modified: 2012-06-27
Hey,

I am trying to parse my JSON string with:

$(function(){
	$.getJSON("http://skimaine.kgconnect.com/wp-content/themes/ski-maine/inc/parse_feeds.php", function(data) {
		//var area = data.items;
		$.each(data, function(i, area){
		   alert(area.resortName);
		});
	});
});

Open in new window


What is the easiest way to get this running, in firebug it says the call is made, but no alert is show. You can see the output when you run it. Not sure what its doing.

My php looks like:

<?php 
$jsonurl = "http://feeds.snocountry.com/conditions.php?apiKey=skimaine$54.maineski118&states=ME";
$json = file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json);
print_r($json_output);
?>

Open in new window


Any ideas? Thanks.
0
Comment
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36545392
why do you want to decode it, just send it back to the client side asap :

<?php
$jsonurl = "http://feeds.snocountry.com/conditions.php?apiKey=skimaine$54.maineski118&states=ME";
echo file_get_contents($jsonurl,0,null,null);
?>
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 36545405
Bingo, that did it! Didnt know if decoded was necessary. thank you!

Ryan
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses four methods for overlaying images in a container on a web page
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now