javascript - json object directly from my view HTML -


i'm using phonegap in order make application, i'm using codeigniter api. data, i'm using simple $.post jquery rest url in codeigniter.

$.post(dir+trad+"/format/json", function(data){     traducciones = jquery.parsejson(data); }, json); 

based upon this, got 2 questions, because don't know if should in different post methods.

the first question is, how data in json format? second question is, there way call json object directly view (html) ? or need using jquery or javascript?

how data in json format?

searching codeigniter+json gives me output class has example:

$this->output     ->set_content_type('application/json')     ->set_output(json_encode(array('foo' => 'bar'))); 

is there way call json object directly view (html)?

generally speaking, if generating json , want use in html, skip generating json , use data directly.

generating json view becomes useful if want make raw data available on network.

if want fetch data on http view, job model. see how send request php?. useful if have 2 different applications. 1 providing web service data , 1 providing user facing application.

if want update page new data after has loaded, usecase json, can javascript (or client side programming language).


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -