JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 15th, 2013, 12:20 PM
superprogrammer superprogrammer is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Posts: 850 superprogrammer User rank is Lance Corporal (50 - 100 Reputation Level)superprogrammer User rank is Lance Corporal (50 - 100 Reputation Level)superprogrammer User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 6 h 16 m 50 sec
Reputation Power: 10
Send a message via AIM to superprogrammer Send a message via MSN to superprogrammer Send a message via Yahoo to superprogrammer
jQuery - JSON to hml and data formatting

I have a page where I make a ajax request and get the data in json format
I need to render this json response as tables in html
Is there any common functions/libraries I can use so that I dont have to loop through this json to render in html?


Also, Is there any data formatting libraries too which can show phone number input as 1111222233 as
111-1222-233
or dates coming from backend - 02/13/2013 as
Feb-13-2013 etc
__________________
Contact info:
Primary email: advanced.programmer@gmail.com
MSN/email: superprg@hotmail.com
AIM: superprg

Reply With Quote
  #2  
Old February 15th, 2013, 09:13 PM
web_loone08's Avatar
web_loone08 web_loone08 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2008
Posts: 658 web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 7 h 53 m 47 sec
Reputation Power: 69
Do a Google search; you will get many results for converting "JSON to HTML".

Code:
<script>

var phone_number = 1111222233;

var backend_date = "02/13/2013";

var months = new Array("January","February","March","April","May","June","July","August","September","October","November","December");

function convert_phone()
{
phone_number = phone_number.toString();
var area_code = phone_number.substring(0,3);
var prefix = phone_number.substring(3,6);
var suffix = phone_number.substring(6,10);
var convertedNumber = area_code + "-" + prefix + "-" + suffix;
alert(convertedNumber);
}

function convert_date()
{
var divider = backend_date.split("/");
var month = parseFloat(divider[0]) - 1;
month = months[month];
var day = divider[1];
var year = divider[2];
var fully_converted_date = month + "-" + day + "-" + year;
alert(fully_converted_date);
}

window.onload = function() {
convert_phone();
convert_date();
}

</script>

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > jQuery - JSON to hml and data formatting

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap