IE encounters issues when dealing with JSON

Using this snippet of javascript along with a json string to transmit data to a flash project.

var flashvars = { 
    xmlFile: 'http://iyt.psu.edu/xml/abington/home.xml',
    preface: 'http://iyt.psu.edu/',
    preload: '{"url":"flash/project.swf","x":"375","y":"237","link":"home","tween":{"prop":"y","begin":"0","finish":"-200","duration":"1"}}'
};

Encountering issues in IE due to the preload line. Any suggestions on what might be causing the problem besides the fact that it's Internet Explorer? ;^)

Answer №1

When dealing with trailing commas, FireFox and Webkit based browsers will display everything correctly. However, in IE, any trailing commas without additional object properties can cause a less obvious problem.

Take note of the extra comma at the end which will lead to failure:

var flashvars = { 
        "xmlFile" : "http://iyt.psu.edu/xml/abington/home.xml",
        "preface" : "http://iyt.psu.edu/",
        "preload" : "{'url': 'flash/project.swf' , 'x': '375 ', 'y': '237', 'link': 'home', 'tween' : {'prop':'y','begin' : '0', 'finish' : '-200' , 'duration' : '1' }}",
}

Ensuring properly formatted JSON that passes the test is always recommended.

var flashvars = { 
        "xmlFile" : "http://iyt.psu.edu/xml/abington/home.xml",
        "preface" : "http://iyt.psu.edu/",
        "preload" : "{'url': 'flash/project.swf' , 'x': '375 ', 'y': '237', 'link': 'home', 'tween' : {'prop':'y','begin' : '0', 'finish' : '-200' , 'duration' : '1' }}"
}

The JSON provided seems fine, but it's worth checking for any possible characters copied from programs like Word.

Answer №2

It could be the forward slash / that requires escaping in JSON strings.

Answer №3

It is recommended to first encode the JSON string using a server-side language or JavaScript tool before allowing AS3 to decode it automatically:

For instance, in PHP:

$flashvars = array(
        'xmlFile' => 'http://iyt.psu.edu/xml/abington/home.xml',
        'preface' => 'http://iyt.psu.edu/',
        'preload' => '<c:out value="{"url":"flash/project.swf","x":"375","y":"237","link":"home","tween":{"prop":"y","begin":"0","finish":"-200","duration":"1"}}'" />'
    );

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

A guide on integrating Google schemas into a Mandrill email template

Having some trouble embedding a code snippet in my Mandrill template to integrate Google Schemas. Each time I try to publish the template, Mandrill refreshes and the code disappears. This is the code I'm trying to include: <script type="applicati ...

Dynamic HTML Table with Ajax Click Event Trigger

I have implemented an HTML table that refreshes automatically every 5 seconds and contains some buttons. The issue I am facing is that the event only triggers before the initial refresh. <?php require_once ('UserTableHtm ...

Transforming a cURL command into its equivalent in pyCurl

Currently, I have a Patch request implemented using cURL. Now, my goal is to accomplish the same functionality in Python: curl -X Patch -H "content-type: application/json" -d '{"activation": {"mode":"activate_immediate"},"transport_params":[{"destina ...

The exceptional speed of jQuery's each method sets it apart

I'm currently facing an issue where I am unable to successfully add the attribute data-size to my parent div. My code snippet is as follows: var width, height; $(".galerie img").each(function() { width = this.naturalWidth; height = this.naturalH ...

Enhancing Error Validation Messages in FormControl to Include More Specific Details

In continuation of my previous inquiry, my objective is to display a customized error message for user inputs. Instead of presenting users with a generic error message, I want to provide them with specific feedback. For example, if the input field only al ...

What is the best way to transfer a list from aspx to javascript?

When populating a table by looping through a list, I aim to pass a row of data to my JavaScript code. If that's not an option, I'd like to pass the list and the ID number for the specific row. How can I achieve this? <%foreach(var item in Mod ...

What are the best ways to resolve the warning from webpack in Express?

I have set up webpack to bundle both the server and client side code... Below is my webpack configuration: const webpack = require('webpack'); const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin&a ...

Discover the process of integrating PWA features into an Express web application

I'm currently in the process of integrating PWA into a web application. I've created a manifest.json file and added it to the head of my page, which is loading correctly. However, the service worker registered in my app.js doesn't seem to be ...

The Sizzle.js error, "Uncaught TypeError: undefined (reading 'expr')," is causing some trouble

$.expr[':'].containsCaseInsensitive = function (n, i, m) { return jQuery(n).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0; }; .expr is not recognized. To ensure it's defined, I included a CDN link below: <script src=&qu ...

Initiate a Material-UI CSS animation when the element comes into the viewport

After conducting some research on CSS animation triggers when an element comes into view, I came across this solution that utilizes the IntersectionObserver and element.classList.add('.some-class-name') While this method is demonstrated in pure ...

Is it possible to preload numerous extensive datasets in the background using ajax?

I'm currently in the process of developing a web application that operates solely on one page and revolves around presenting various table data in grids. There are approximately 30 different tables stored in the database, with any of them being access ...

Determine the Total of a Column in jqgrid

Hey there, I'm looking for a way to calculate the total sum of the "montant" column in my jqgrid and then display it below the grid as "Total: *total amount*". Here is the code for my grid: <sjg:grid id="gridtable" caption="Quittance Payé ...

There was an error due to a TypeError: The 'page' property cannot be read because it is undefined

Can anyone assist me with an Angular issue I'm facing? I've been working on integrating server-side pagination, but no matter how many times I revise my code, I keep encountering the same error message: ERROR TypeError: Cannot read properties o ...

What are the best practices for integrating QML with Java?

How can QML be interfaced with Java when developing the GUI and API for a linux based device? ...

How can I create a custom validator in Angular 2 that trims the input fields?

As a newcomer to Angular, I am looking to create a custom validator that can trim the input field of a model-driven approach form. However, I have encountered difficulties during implementation. When attempting to set the value using setValue() within th ...

Identifying the Operating System of Your Device: iOS, Android or Desktop

I am in need of displaying different app download links based on the user's operating system. This includes IOS, Android, or both if the user is accessing the page on a Desktop device. I am currently utilizing React and Next.js for this project. Unfor ...

Using res.locals with TypeScript in Next.js and Express

In my express - next.js application, I am transferring some configuration from the server to the client using res.locals. My project is written in typescript and I am utilizing "@types/next": "^8.0.6". The issue at hand: typescript is throwing an error st ...

When trying to retrieve UTF-8 from JSON in my Android app, I am receiving a different encoding, possibly ISO-8859-1. What could be causing this unexpected behavior

When using the volley-library to retrieve JSON data from a server, I encountered an issue. The JSON data on the server looks like this: { "timeLabel": "10.30 – 12.45", "location" : "Конференц-зал 4", ...

Converting Java collections into JSON format

My task requires my program to generate JSON data in the following format: { "success": { "code": 1, "desc": "success" }, "response": { "res1": [ { "Item": "item1", "Description": [ ...

retrieving the selected date from the calendar widget

I'm utilizing jQuery's datepicker to collect date inputs from users. The form is structured as below: <form id="myform" action="/graphs/get_builds" method="post"> Start: <input type="text" id="start" /> End: <input type="t ...