rss
twitter
  • Showcase
  • Carrières
  • Support
  • GitLab
  • Espace client
  • Contact

An invalid or illegal string was specified » code : « 12

0

INDEX

A typical Firefox javascript error !

Symptoms

– the problem seems to occur only in Firefox (as of 02/2011)
– you will hardly notice it in Firefox’ debug window, however the Firebug extension show it clearly (see screenshot below)

img1

Error message

An invalid or illegal string was specified » code: « 12
[Stopper sur une erreur] (99 out of range 41)

Context

– You are probably parsing XML, JSON, distant data
– You are probably using a javascript framework such as jQuery or Prototype
– You are probably trying to display, or store, part of the parsed data

The cause

Analyzing some data before they are parsed (in my case, it’s an XML feed of regions all across the globe), I’ve noticed some data were missing (see screenshot). To monitor my data, I’ve simply used console.log:

if (type_ville == types_villes) {
        locations.push(Array(nom, latlng[0], latlng[1], type_ville, nid));
        console.log(Array(nom, latlng[0], latlng[1], type_ville, nid));
}

img2

Kind of missing data in an XML context

I’ve noticed that data can be considered missing whether they are really blank, and also if they do not respect an established schema. In my case, I was trying to parse an array while the user input was missing the comma separator. (see code below).

Sample 1: wrong datatype

<node>
	<nom>
		<fr>Inta</fr>
		<en>Inta</en>
		<ru>Инта</ru>
	</nom>
	<marker_ville>66.0331421	60.1656114</marker_ville>
	<type_ville>Lieu de déportation</type_ville>
	<Nid>77</Nid>
</node>

The field marker_ville should contain an array, but the comma is missing. Firefox is blocked the wrong datatype.

Sample 2: missing data

<node>
	<nom>
		<fr>Estonie</fr>
	</nom>
	<marker_ville></marker_ville>
	<type_ville>Lieu de résidence</type_ville>
	<Nid>281</Nid>
</node>

Firefox won’t bypass this node even if marker_ville is empty. Chrome and other webkit-based browsers will, thought. Haven’t tested under IE.

Sample 3: missing data with shortened tag

<node>
	<nom>
		<fr>Kiev</fr>
		<en>Kiev</en>
		<ru>Киев</ru>
	</nom>
	<marker_ville/>
	<type_ville>Lieu de départ</type_ville>
	<Nid>70</Nid>
</node>

I’ve tried this sample manually just to check. Even if marker_ville is empty and well-formed, Firefox won’t bypass it

Finally…

Having checked my data again, I couldn’t notice any undefined field (see screenshot below). After commented the console.log(), I was happy to see that my script was working again 🙂

img3

DATE 02 Mar 2011
by : Germain
Author / Auteur

Social Share / Partager

    Leave a Reply / Répondre Annuler la réponse

    *
    *

    More in Front-end : javascript, jQuery

    • jQuery UI : autocomplete qui "start with" au lieu de "contains"
    • Horaires personnalisés avec wdCalendar
    • jQuery Supersized plugin : load images from a nested list
    • jQuery : vérif checkbox cochée, choix dans liste select
    • jQuery browser version detection quick memo

    Search the blog

    Blog categories

    • Front-end : HTML, CSS (13)
    • Workflow (1)
    • Front-end : javascript, jQuery (33)
    • Back-end : PHP, CMS (42)
    • Back-end : SQL, MySQL (20)
    • Sysadmin : Linux, Apache, GIT (75)
    • Designers : tools, advice (2)
    • Desktop : OS X (37)
    • Desktop : Microsoft (12)
    • Uncategorized (8)

    ITALIC™ Resources

    • Paramètres de connexion au serveur mail
    • Graphistes : séduire un développeur web
    • Dév front : nos bonnes pratiques
    • Mailing : nos (bonnes ?) pratiques
    • Environnement de travail Mac

    Recent posts

    • Autoriser le chargement de contenus mixtes non-https dans Chrome (Mac)
    • Afficher les logs MySQL
    • Recevoir un mail lors de la connexion root à un serveur
    • Changer l’interclassement de plusieurs tables MySQL à la fois (ou presque
    • Maildev : tester l’envoi de mails durant ses développements
    © 2008-2017 ITALIC™ • 8 bis rue Abel • 75012 PARIS • Tel +33 (0)1 48 44 46 35 • RCS PARIS 508 228 772 • Powered by WordPress & GoodLayers
    Nous utilisons des cookies pour vous garantir la meilleure expérience sur notre site web.
    Cookie settingsACCEPTER
    Manage consent

    Privacy Overview

    This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
    Necessary
    Toujours activé
    Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
    Non-necessary
    Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
    Enregistrer & appliquer