Encountering the Extjs 3.4 error ERR_UNKNOWN_URL_SCHEME while trying to access a legitimate JSON

Using Extjs 3.4, I am working on a simple ajax request:

 Ext.Ajax.request({
    url: "localhost:3000/offers.json",  
    success: function(response, opts) {
      var obj = Ext.decode(response.responseText);
      console.dir(obj);
   },
   failure: function(response, opts) {
      console.log('server-side failure with status code ' + response.status);
   }
});

The localhost:3000/offers.json is powered by Rails 4 back-end and it is functioning correctly:

$curl localhost:3000/offers.json              
[{"id":1,"desc":"a description","img_link":"www.google.come","product_link":"www.google.come","code":"927341","price":"20.29","special_price":"13.99","saving":"31.0","created_at":"2014-06-23T15:45:11.404Z","updated_at":"2014-06-23T15:45:11.404Z"}]

So the back-end appears to be working without any issues.

However, when trying to call the json url using Ext.Ajax.request, an error pops up in the Chrome console:

OPTIONS localhost:3000/offers.json net::ERR_UNKNOWN_URL_SCHEME ext-base.js:21
i ext-base.js:21
Ext.lib.Ajax.k.request ext-base.js:21
Ext.extend.request ext-all-debug.js:4636
ajaxSearch_function grid-ajax.js:8
Ext.Button.Ext.extend.onClick ext-all-debug.js:31872
h ext-all-debug.js:5215
server-side failure with status code 0 

Any thoughts or suggestions on how to address this issue?

Answer №1

When attempting a cross-domain call with Ajax, it may not be supported.

A solution is to utilize JsonP, which is designed for loading data from other domains.

Take a look at this example and consider incorporating it into your code:

http://try.sencha.com/touch/2.0.1/docs/Ext.data.JsonP.1/viewer.html

I hope this information proves helpful.

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

I need to update a JSON file on the server by adding a new object to the existing array using the fs.appendFile function

I have a JSON stored on the server like this: [{"a":1}, {"a":2}] and I'm wondering if there is a way to add an object at the end without having to rewrite the entire file on the server. As a workaround, I have been omitting the brackets and adding the ...

Having difficulty retrieving data despite providing the correct URL

I am encountering an issue with a fetch function designed to retrieve a JSON web token. Despite verifying the correctness of the URL, the function is not functioning as expected. Below is the front-end function: const handleSubmit = async (e) => { ...

Displaying PDF files on the internet without allowing them to be downloaded

How can I display PDF files on my website without allowing them to be saved or downloaded? Is there a way to prevent browsers from saving or downloading the PDF files? ...

Importing JSON file components into Aframe using a URL

I'm attempting to import a terrain model from a json file by providing a url in my aframe scene. I have been referencing code from another project, but I am struggling to comprehend how to structure the json file url similarly to theirs: /* global AF ...

Obtaining a value from a KeyValuePair stored in a single cell within an Oracle database

Consider a scenario with the following table: id name address Doc 1 {1:mark,2:john} {1:Home,2:Work,3:Club} {NI:299,Pass:A159} 2 {1:Max,2:Mo} {1:Home} {NI:300011} The task is to write a query t ...

displaying data from multiple sources using JSON in amcharts

I am trying to implement AmChart and retrieve data for my charts from MySQL using JSON. Here is the JavaScript source code I am using: AmCharts.ready(function () { //generateChartData(); createStockChart(); }); function createStockChart() { ...

React conditional statement within a map function embedded in a JSX element

Below is the function I have created to generate tabbed items: function ConstructTabs(props) { const tabs = props.tabs; const makeTabs = tabs.map((tab, index) => { <React.Fragment> <input className="input-tabs" id ...

Discontinuing the fieldset tab interface feature from a Dexterity content type

I am looking to modify a condition to prevent the loading of certain javascript code when inserting an object of my content type. The current condition works only when editing the object: <?xml version="1.0"?> <object name="portal_javascripts"> ...

How can I seamlessly combine CoffeeScript and TypeScript files within a single Node.js project?

When working on a server-side node project utilizing the standard package.json structure, what is the best way to incorporate both Coffeescript and Typescript files? It's crucial that we maintain the availability of npm install, npm test, and npm sta ...

Deciphering JSON strings using JavaScript

Here is a string that I am trying to parse using Json: {\"description\": \"PSY - Gangnam Style (\\uac15\\ub0a8\\uc2a4\\ud0c0\\uc77c) \\n\\u25b6 NOW available on iTunes: h ...

Automating the process of running npm start on page load: A guide

Recently, I've been delving into learning npm in order to incorporate it into a website. I'm curious about how exactly it is used within a website - do you typically need to execute the command "npm start"? How does this integration work for a li ...

I require the json data to be divided into smaller segments

I have a JSON file that I need to modify by splitting the "Vs" column into two separate columns. I want to create new columns named team 1 and team 2 by splitting the data after 'vs'. Can anyone guide me on how to achieve this using a python scri ...

Switch out HTML dynamically using JavaScript/JQuery, embracing the principles of DRY coding

As a newcomer to front-end development, one issue I frequently encounter is avoiding repetition when dynamically generating HTML using JS/jQuery. Imagine you have a DOM object that has various states. Typically, all you need to do with JS is switch betwee ...

Remove bulleted list from HTML using JavaScript DOM

My task involved deleting the entire "agent" array using the removeChild() function, requiring the id of a <ul> element. However, I faced an issue as I couldn't set the id for the "ul" due to using the createElement() function. //old code < ...

The IsArray() function in IE8 encounters an issue where it expects an error object

I am interested to know why IE8 is having trouble with this line of code: if (isArray(obj)) When I check in the IE8 javascript console, I see the following: >>obj {...} >>typeof(obj) "object" >>Object.prototype.toString.call(obj) "[obj ...

Sending Ajax requests to web services hosted on a dual-node NLB

I am currently managing a two-node NLB configuration where multiple web services need to be accessed from the client-side using ajax POST requests. When visiting the page at: http://clusternode1/ everything works smoothly. Similarly, when accessing it f ...

Solving the challenge of converting images to text using react-native and the @react-native-ml-kit/text-recognition package

As I work on my react native project, I have encountered a challenge. I am trying to implement a feature that allows users to either take a photo or select one from their library. Once the image is chosen, I want to extract all the text from it and display ...

What is the best way to include my PHP session variable within my JavaScript code?

i have a dynamic table that the enables to perform CRUD operations on a database. after logging in the user is directed to index.php, here a table is displayed with values stored in the database table "ajaxtable". i have joined "ajaxtable" table and "membe ...

A guide on verifying a username and password via URL using JavaScript

As I work on developing a hybrid application using the Intel XDK tool and jQuery Mobile framework for the user interface, one of my current tasks is implementing a login function. This function involves simply inputting a username and password and clicking ...

Issue with custom fonts not showing in PDFs when using Puppeteer, even though they are displayed in screenshots

I've been working on dynamically creating PDF files using the puppeteer library, but I'm facing an issue where the generated PDF doesn't display the custom fonts (.woff) that I have specified. Instead, it defaults to using the system font, T ...