Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 2nd, 2015, 04: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


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 07: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 07:50 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.