Solved

Parse JSON with PHP and read with jQuery

Posted on 2011-09-15
2
304 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

738 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