Despite receiving a 200OK response from the AJAX request, the operation still fails even though the return data

Update: The reason for the incorrect information returned in my case was due to attempting to use JSONP to connect to a CORS data setup, which the server did not have configured for my specific computer's access. I needed to engage with someone and adjust the permissions of the configuration file on the server. This turned out to be the underlying issue, as I initially thought CORS and JSONP were interchangeable, but they have distinct ways of implementation and require certain server settings.

Summary: I am facing an $.ajax request failure when querying a server for data. The response indicates success, yet there is a disconnect somewhere.

Upon inspecting the Network tab, I can SEE the expected response. Unfortunately, it remains elusive.

Errors: While it reports a failure, the actual return is as follows:

{"readyState":4,"status":200,"statusText":"success"}

This suggests that the client side flagged something. The response includes:

["Asset","AssetElementDefMap","AssetFile","...multiple elements here...
WorkingSet"]

The Headers are listed below:

**Request**
URL:http://xx.xxx.xx.x/mas3/DataSources/inspecttech.inspecttech/Schema/Classes/?callback=jQuery172021616409649141133_1374243099954&_=1374243124683
Request Method:GET
Status Code:200 OK
**Request Headers** 
...
**Response Headers**
...

UPDATE: AJAX REQUEST CODE:

var u = "myusername";
var p = "mypass";
var up = u + ":" + p;
$.ajax({
    type: "GET",
    url: "http://xx.xxx.xx.x/mas3/DataSources/inspecttech.inspecttech/Schema/Classes/",
    contentType: "application/json; charset=utf-8",
    dataType: "jsonp",
    headers: {Authorization: "Basic "+up},
    success: function (r) {
        alert("Success: " + JSON.stringify(r));
    },
    error: function (r) {
        alert("Failure: " + JSON.stringify(r));
    }
});

Answer №1

Here is the response:

The data returned has a Content-Type of application/json and includes items such as "Asset", "AssetElementDefMap", and "WorkingSet".

This is not a JSONP script, but rather plain JSON (without the callback function). Due to cross-domain restrictions, accessing this resource is prohibited - even attempting to execute it as a script will fail, despite the resource loading with a status of 200 OK.

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

The console logs indicate success for every call, but unfortunately Twitter is not displaying the retweets

Hey there! I'm having some trouble with calling a function and it's not working as expected. var T = new Twit(config); var retweet = function() { T.get('search/tweets', {q:'#python3, #nodejs, python3, nodejs,', count :5 }, f ...

Is it possible that WebdriverIO is unable to retrieve the value for an input

Currently, I am in the process of automating tests specifically for a web application on Safari browser. However, I have encountered some challenges along the way. It appears that webdriverIO is not performing very well with Safari in my environment, which ...

Make sure to scan for duplicates prior to inserting into a JavaScript array

I am working on a React function that involves adding an object to a JavaScript array. Here is the code I have so far: selectAnimalHandler = (animal) =>{ console.log(animal.id) if(this.state.animals.find(ani => ani !== animal )){ this.s ...

A guide on extracting text content exclusively from Markdown files using Javascript

I've been working on a blogging platform with Vue that serves Markdown (*.md) files for posts. My goal is to display a list of published posts on the main page along with a preview of the first 30 words of each post. Currently, I have a function that ...

Having trouble retrieving data from one object nested within another object?

Here is the specific data that I am referring to [ { "id":1, "date":"2020-01-02", "start_time":"11:32:25", "end_time":"11:32:26", "edit ...

Achieving Text Alignment in React Native

I am currently working on styling my project, and I have added a slug description which I hardcoded temporarily to improve its appearance. However, there are two issues that I am trying to address. Firstly, I am unable to align the slug text properly. Seco ...

Ionic utilized the $http service and was unexpectedly triggered two times

$scope.login = function(email,password){ $http({ method: 'POST', url: 'http://example.com/login', headers: { 'owner': $rootScope.secret }, data: {email:email, password:password } }).then(function successCallback(response) { co ...

Sleek descending motion effect

I have created a simple function, but it is not animating smoothly and seems to lag... I am using it for a div sized at 1600x700 pixels on page load $(document).ready(function(){ $('#slider').slideDown(500); }); Is there any way to ensure s ...

Retrieve the stylesheets located within the <head> section of an external webpage and load them onto the current page

Trying to figure out a solution, I received an interesting request from a friend. They asked for help in creating a webpage that can dynamically pull a div tag from an external page (on a different server). To accomplish this, I utilized jquery's .loa ...

Verify the form value for condition evaluation without the need to submit the form

I've been utilizing the following code: <html> <head> <script> function validatePfin() { var x1 = document.forms["pfin"]["cash"].value; var x2 = document.forms["pfin"]["all_assets"].value; var x3 = document.forms["pfin"]["all_debt"] ...

Crafting a personalized arrow for sorting headers in Angular Material

Currently working on an Angular 5 project and I'm looking to implement a custom sort icon in the header. The goal is to achieve a similar effect to this example, without using the default arrow. I attempted to modify the CSS styles, but it wasn' ...

Saving a multitude of data to a JSON file

Trying to tackle a seemingly simple task - writing the number 1000000000000000000000 to a JSON file using NodeJs. The constant is already defined as follows: const NUM = 1000000000000000000000 But when attempting to write it, the output becomes 1e+21. Al ...

leveraging the power of JQuery and Ajax for submitting a form

I am looking to implement ajax functionality for form submission I want to achieve this using radio buttons instead of a submit button Essentially, when a radio button is clicked, the form should be submitted or posted My PHP page needs to determine whi ...

Generate list items based on a PHP array using JavaScript

Upon fetching data from my database, I receive a PHP array structured as follows: $dbResult = array([0] => array([a] => 1 [b] => 1 [c] => 1) [1] => array([a] => 2 [b] => 2 [c] => 2) [3] => arr ...

Troubles with displaying Google Maps on Ionic Modal

Having trouble displaying the google map in an ionic modal - it shows up fine on the page but not in the modal. Any help would be greatly appreciated, as this is quite frustrating. Below is my controller js and code for the ionic modal. $ionicModal.from ...

Obtaining JSON data in Android's splash screen view

In my attempt to develop an app, I encountered an issue. The app should first display a home page for 2 seconds. Below is the code snippet... public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { ...

JQuery Validation - Implementing real-time validation on button click instead of form submission

I am currently attempting to use JQuery Validation with WebForms/html. I have simplified the HTML code below, displaying only the necessary elements: <input id="txtEmail"/> <input id="txtTicketID"/> <a id="create" href="#">Create a new t ...

What is causing my JS/JQuery code to only function in the console of a web browser?

I am having trouble with the $(element).scroll(function(){}); function. When I put it into a js file, it does not work properly, but when I enter it directly into the console (just the scroll func), it works fine. My goal is to implement scrolling paginat ...

Utilizing *ngIf within a loop to alternate the visibility of table rows with a designated class upon clicking on rows with a different class in Angular 2

I have created a table that displays data, and within this table there are 2 tr elements with the classes default and toggle-row. When I click on a tr element with the class default, it should only toggle the corresponding tr element with the class toggle- ...

`the issue of $scope object not being passed correctly to ng-if and ng-class ternary conditions

**app.js:** $scope.servers = [ {name:'SQL Server', status:"up"}, {name:'Web Server', status:"down"}, {name:'Index Server', status:"down"} ]; **index.html:** <table> ...