What could be the reason for this JSON being considered "invalid"?

Despite passing validation on jsonlint, both Firefox and Chrome are rejecting this JSON:

{
    "messages": [
        {
            "subject": "One"
        },
        {
            "subject": "Two"
        },
        {
            "subject": "Three"
        }
    ],
    "totalResults": 10
}

The specific error message is "invalid label" related to "messages."

This is how the data is being loaded:

var store = Ext.create('Ext.data.Store', {
    model: 'MyModel',
    autoLoad: true,
    pageSize: 3,
    proxy: {
        type: 'jsonp',
        url: 'http://localhost:8080/document-viewer-1.0/testdata.json',
        reader: {
            root: 'messages',
            totalProperty: 'totalResults'
        }
    }
});

Solution:

This issue was due to my own oversight. I neglected to encapsulate the JSON file structure with the JSONP callback name.

Answer №1

Your JSON data is correctly formatted, however there is a small error.P

To fix this issue, you should update the following:

type: 'jsonp',

to

type: 'json',

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

Finding the Client's Private IP Address in React or Node.js: A Comprehensive Guide

Issue I am currently facing the challenge of comparing the user's private IP with the certificate's IP. Is there a method available to retrieve the user's private IP in react or node? Attempted Solution After attempting to find the user&a ...

Executing JavaScript - Triggering an 'onClick' event within a For loop to dynamically load multiple hyperlinks

I am currently working on creating a listview using JSON data. However, when I call an 'onclick' function from a For loop, the link opens in a new window and loads three URLs into the browser's URL input. Is there a way to modify the code be ...

How can we best store the component's state in the URL in AngularJS?

I am working with a reusable widget that has its own state. This state includes the content of the search bar (2), one or more select boxes (1), and the tree where the user can pick the currently active element (3). My goal is to create a locationManager ...

Is it advisable to incorporate await within Promise.all?

Currently, I am developing express middleware to conduct two asynchronous calls to the database in order to verify whether a username or email is already being used. The functions return promises without a catch block as I aim to keep the database logic se ...

Utilizing Angular to intercept AJAX requests, verifying internet connectivity before proceeding with sending the request

In my Angular (with Ionic) app, I have this code snippet: my_app.factory('connectivityInterceptorService', ['$q', '$rootScope', function ($q, $rootScope) { var connectivityInterceptorServiceFactory = {}; var _request ...

There are zero assumptions to be made in Spec - Jasmine analyzing the callback function

I've encountered a challenge with a method that is triggered by a d3 timer. Each time the method runs, it emits an object containing several values. One of these values is meant to increase gradually over time. My goal is to create a test to verify wh ...

What steps should I follow to track an event using Firebug?

When I examine the element, how can I discover all of the events that are attached to it? ...

Guide on how to extract data from a local JSON file, retrieve images from the JSON object's URL, and store the image paths in a Model

I currently have the following JSON saved locally: { "country":[ { "alpha2Code":"AF", "alpha3Code":"AFG", "flag":"https://raw.githubusercontent.com/DevTides/c ...

Having trouble sending the selected value from a dropdown list to the server using $.ajax

I am embarking on my first project using JQuery (jquery-3.0.0.min.js) and JavaScript. My goal is to build a straightforward web form that connects to a database through a Web API. The form consists of various input text fields and two select dropdowns. ...

Ways to extract single JSON entities from a consolidated JSON structure

I am facing a challenge with parsing multiple JSON objects within a single large JSON object. Currently, the entire JSON object is being stored as one entity, but I need to parse and store them separately in MongoDB. Below is the code snippet I am using. ...

Is it possible for AJAX to update a button's argument?

After successfully using AJAX to extract a data value from a button click, I am now looking to pass this value as an argument to another button on the same page. Is there a way to achieve this seamlessly? Sample code from test.html: <a href="#" onClic ...

ClickAwayListener is preventing the onClick event from being fired within a component that is nested

I am encountering an issue with the clickAwayListener feature of material-ui. It seems to be disabling the onClick event in one of the buttons on a nested component. Upon removing the ClickAwayListener, everything functions as expected. However, with it e ...

Bluebird Enthusiastically Predicting the Outcome of a Complex Operation

Lately, I've been heavily utilizing Bluebird in my HAPI API development. However, I've encountered a perplexing issue that has left me puzzled due to either my understanding or lack of experience. Below is an example demonstrating the challenge ...

Ways to make JavaScript cycle through a set of images

I'm having trouble trying to set up a code that will rotate multiple images in a cycle for an image gallery I'm working on. So far, I've only been able to get one image to cycle through successfully. Any help or suggestions would be greatly ...

Converting MySQL Bit Type to Swift 3: A Comprehensive Guide

My current database utilizes a Bit type object to represent a boolean variable. https://i.sstatic.net/1qI2j.png However, when attempting to retrieve this data from MySQL to Swift 3, it returns Nil. The PHP file functions correctly as running the PHP code ...

The Vuetify Jest button trigger fails to function properly despite utilizing a spy

Recently delved into the world of Vue.js and Jest to see how they interact. I watched some tutorials and then decided to give it a go myself, but ran into trouble with getting the trigger click to work. Within my component, I have a login button, which is ...

The Forward and Back Buttons respond based on the current position of the caret

Exploring the concept of a Keypad-Login. I am trying to create Back and Forward buttons. However, the back and forward buttons are currently inserting the letters at the end of the input value instead of at the caret position. The input field is disabled, ...

Resize drop zone with drag and drop functionality

I am using jQuery for dragging and dropping elements, but I am facing an issue. When I resize the drop zone while starting to drag an item, it seems like the previous size of the drop zone is still being used as the space. Is there a way to fix this? ...

NextJS for Self-hosting Fonts

I'm facing difficulties with self-hosting webfonts in my NextJS application. The browser is trying to access the fonts using this URL: localhost:3000/_next/static/css/fonts/Avenir.woff2 However, the actual path for these fonts is: _project_dir/static ...

After transitioning to a different laptop, I encountered unexpected ES6 syntax errors while trying to compile my Vue project

I recently acquired a new laptop and encountered an issue. After pulling my Vue project from GitHub, I proceeded to run npm install, followed by npm run dev. ERROR Failed to compile with 1 errors 1:38:10 PM ...