Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Parse JSON with PHP and read with jQuery

Posted on 2011-09-15
2
Medium Priority
?
320 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 83

Accepted Solution

by:
leakim971 earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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…
Suggested Courses

877 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