Solved

Parse JSON with PHP and read with jQuery

Posted on 2011-09-15
2
305 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

729 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