You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Shazron Abdullah (JIRA)" <ji...@apache.org> on 2013/04/26 01:28:16 UTC

[jira] [Resolved] (CB-3221) FileReader not working on Cordova 2.6.0 or greater

     [ https://issues.apache.org/jira/browse/CB-3221?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Shazron Abdullah resolved CB-3221.
----------------------------------

    Resolution: Invalid

False positive - this is actually an exception in your onloadend handler. When event.target.result is the empty string, and you call JSON.parse, it throws an exception.

Add this code in your head tag to see it:
{code}
<script>window.onerror = function(err,fn,ln) {alert("ERROR:" + err + ", " + fn + ":" + ln);};</script>
{code}

Fix your code like so:
{code}
reader.onloadend = function(event) {
	obj = {};
	try {
		obj = JSON.parse(event.target.result);
	} catch (e) {
		console.log(e);
	}
	document.getElementById('rloadend').innerHTML = 'true';
	document.getElementById('rdata').innerHTML = JSON.stringify(obj);
};
{code}
                
> FileReader not working on Cordova 2.6.0 or greater
> --------------------------------------------------
>
>                 Key: CB-3221
>                 URL: https://issues.apache.org/jira/browse/CB-3221
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: iOS
>    Affects Versions: Master, 2.6.0
>         Environment: iOS 6.1.3/Xcode 4.6.2
>            Reporter: Rob Gillan
>            Assignee: Shazron Abdullah
>             Fix For: 2.7.0
>
>         Attachments: index.html
>
>
> In upgrading from production 2.5 to 2.6 we have found that the FileReader events do not fire beyond onloadstart. Thus reading files do not work as there is no onloadend or returned information.  Noticed first on an iPad3 but then verified under XCode simulator.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira