Sam Croft

Full-stack developer

Loading JSON data into an Ionic app using Angular JS’ $http service

  • 31 comments

Filed in: angular, api, cordova, ionic, javascript

Ionic Framework and Angular JS logo

Several years ago I wrote an article about loading data into a PhoneGap app. The article detailed using jQuery’s $ajax method to load JSON data into a simple PhoneGap app. People are still commenting on this article today, so I figured I’d write an up to date version on the same subject, but based around Ionic.

I’ve been working with Ionic a lot of last couple of months. I love it. Using it has gotten me all excited again about hybrid app development. So I thought I’d get back into writing and talk about how I use Angular JS’ $http service to load data into an Ionic app.

(more…)

Tutorial: Using PHP’s JSON encode and decode functions to handle data sent to and from your app

  • 6 comments

Filed in: api, apps, JSON, PhoneGap, php

JSON makes dealing with data in your app exceptionally easy and manageable. The best part about JSON is you can look at it and understand it. It’s not like the confusing spaghetti DOM that you get with XML, it’s a lean minimal representation of your data. If you’re dealing with chunks of data in your app, you want to be using JSON.

So while your app will happily eat up all the JSON you can throw at it, you still need to make it in the first place – and/or have a server side app that is capable of reading it. If, like me, you use PHP to handle things on a server then things are pretty straightforward. You can use PHP’s json_encode and json_decode functions. Encode will take your arrays, or objects, and create a JSON string of your data. While decode will take a JSON string, sent from your app, and turn it into an array or object.

(more…)