Solved

Parse JSON with PHP and read with jQuery

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
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 …

707 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

13 Experts available now in Live!

Get 1:1 Help Now