Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: HTML5, JavaScript and jQuery 24-Hour Trainer
This is the forum to discuss the Wrox book HTML5, JavaScript and jQuery 24-Hour Trainer by Dane Cameron; ISBN: 978-1-119-00116-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: HTML5, JavaScript and jQuery 24-Hour Trainer section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 2nd, 2015, 05:01 PM
Registered User
Points: 27, Level: 1
Points: 27, Level: 1 Points: 27, Level: 1 Points: 27, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2015
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
Default Chapter 34 Files

HI,

i follows the filereader API practice from page 304 to page 307, but my code does not seem to work, the error message is "Uncaught TypeError: this.store is not a function"

the following is the code i entered:

$(screen).find('#importJSONFile').change(function( evt) {
var reader = new FileReader();
reader.onload = function(evt) {
var contacts = JSON.parse(evt.target.result);
for (var i = 0; i < contacts.length; i++) {
this.store(contacts[i]);
}
location.reload();
}.bind(this);
reader.readAsText(evt.target.files[0]);
}.bind(this));

and i think this is my store function:

function store(contact) {
var contactsStored = localStorage.getItem('contacts');
var contacts = [];
if (contactsStored) {
contacts = JSON.parse(contactsStored);
}
contacts.push(contact);
localStorage.setItem('contacts', JSON.stringify(contacts));
}


Please let me know how to rectify this.

Many thanks in advance
Reply With Quote
Reply


Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 34 Ex.2 Mech_1000 BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer 3 April 3rd, 2013 08:45 PM
The chat 34 fly_fish BOOK: Professional C# 4.0 and .NET 4 0 November 16th, 2012 09:11 PM
Page 34 - Projects flapjack BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 April 3rd, 2010 08:50 AM



All times are GMT -4. The time now is 02:19 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.