There was an issue with the AJAX call: Error - NetworkError: DOM Exception 19

Encountered an issue when attempting to perform a cross domain ajax request.

Error message: NetworkError: DOM Exception 19

Seeking assistance with this problem. Feeling very stuck and frustrated :(

Answer №1

Encountered an issue in Chrome when making synchronous requests:

let request = new XMLHttpRequest();
request.open("GET", url, false); // false indicates synchronous call
request.send();

Switching to asynchronous (which was my original intention) resolved the error.

Upon further investigation, I realized that the server was rewriting the URL. Using the rewritten URL prevented the error from occurring. This behavior seemed like a bug specific to Chrome, as Safari handled the synchronous calls with non-rewritten URLs without any issues.

Considering that synchronous XMLHttpRequests are deprecated, I'm undecided about reporting this potential bug.

Answer №2

One mistake that is frequently made is attempting to send a https request to a server that is set up for http connections.

Answer №3

In order to make cross-domain AJAX calls function properly, I implemented a solution using PHP on the server side.

getRemoteUrl.php

<?php
if (preg_match("/^[();[]{}]+$/", $_GET['url'])) {
  //Handle malicious input
} else {
  $ctx = stream_context_create(array('http' => array('timeout' => 10)));

  if (!(@$contents = file_get_contents($_GET['url'], 0, $ctx))) {
    //Action in case of failure
  } else {
    //Action in case of success
    echo $contents;
  }
}
?>

Then, you can call the PHP file and utilize the output as though you were accessing the website directly.

function GetXmlHttpObject() {
  if (window.XMLHttpRequest) {
    return new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    return new ActiveXObject("Microsoft.XMLHTTP");
  } else {
    return null;
  }
}

var xmlhttp = GetXmlHttpObject();
if (xmlhttp === null) {
  //Your browser does not support XMLHTTP!
} else {
  xmlhttp.open("GET", "getRemoteUrl.php" + "?url=someRemoteUrl", false);
  xmlhttp.send();
  var webpage = xmlhttp.responseText;
  //Perform actions with retrieved webpage content
}

It is advisable to use asynchronous operations instead of synchronous ones for better performance. If PHP is not your preferred choice or unavailable, similar solutions can be implemented using other server-side languages.

Answer №4

Error code DOM Exception 19 indicates a "Network Error". Have you verified that the URL being used in your Ajax call is accessible?

If the server allows it, cross domain requests can be made! Prior to the GET/POST call, the browser sends an OPTIONS request to the server to confirm if cross domain requests are supported. Make sure to verify if the server permits cross domain requests. For further information on cross domain requests, you may find this article helpful: Understanding CORS

Answer №5

To overcome the cross-domain policy restrictions of a server, you have the option to utilize Korz. Simply include this line in your code:

<script src="//tomodo-tools.s3.amazonaws.com/tomodo.korz-0.5.js"></script>

Add this script to the <head> section of your website and all cross-domain requests will be redirected through tomodo.me, ensuring that their

Access-Control-Allow-Origin header
is set to '*'

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

Trouble with component not refreshing upon store modification in Vuex

Summary: If you prefer, I have a video detailing my issue: https://youtu.be/Qf9Q4zIaox8 Concern with Navbar Component Not Updating on Store Change. The issue I'm facing involves the Navbar component not updating when there is a change in the store. ...

Build dynamic dropdown menus in Angular.js using cookie data

I'm facing an issue with populating a three-tier dependent dropdown in Angular with saved cookies. Sometimes, all three tiers populate correctly, but other times they show as blank strings or only partially populated. Upon inspecting the HTML code, I ...

Guide to setting up nodejs modules within a specific app directory on your machine

Currently, I am enrolled in a node.js course through frontendmasters.com. In this particular course, it seems to have been recorded at least a year or two ago. The instructor initiates by setting up an application directory called 'express', then ...

Is the iCheck feature designed to block all parent click events?

I've developed an "interaction tracker" system that collects anonymous data on clicked page elements. By implementing an event listener for clicks on the body, I can track interactions with any element on my site successfully. However, interestingly ...

The JavaScript filter function will only return arrays that have matching IDs

How can I filter out book data based on the author's id? I have a list of books with various author ids, and I want to only return the books that match a specific author id. However, my current filtering method doesn't seem to work correctly as i ...

Exploring jasmine-node: unraveling the mysteries of errors

As I embark on my journey to learn JavaScript, I decided to tackle some exercises on exercism.io. This platform provides pre-written tests that need to be passed. While things were going smoothly initially, I hit a roadblock with the latest exercise where ...

What steps should I follow to recreate this PHP hashing method in Node.js?

I am currently trying to replicate a password hashing algorithm in node.js (using LTS version 14.x) that was initially coded in PHP (version 7.2). Despite my efforts, the node.js implementation I have created seems to deviate from the original after the fi ...

Update the content retrieved through ajax periodically

Looking to set up a periodic update for this ajax fetch function, say every 10 seconds. I've tried a few approaches but none seem to work as expected. That's why I'm reaching out here for help. So, any idea how I can refresh the content ev ...

Implementing a versatile single input search feature with autocomplete in MVC 6 that can search across multiple columns

I am working with two tables: Company and Category. I need to retrieve two columns from the Company table and one column from the Category table when a user types in the textbox. An example of the search parameters is as follows: --- CategoryName Suburb S ...

Displaying Buffered Geometry in React-Three-Fiber

I am currently attempting to implement the example found at in a React-Three-Fiber environment. My code is encountering several issues. Firstly, I am consistently receiving the following warning in Chrome: [.WebGL-0x26d30384f700] GL_INVALID_ENUM: Enum i ...

Attempting to modify the color of a selected Three.js object causes all objects in the scene to have their colors altered

For example, check out this JSFiddle link. The interesting part occurs during the mousedown event: var hits = raycaster.intersectObjects( [object1, object2, object3] ); if ( hits.length > 0 ) { console.log(hits[ 0 ].object) hits[ 0 ].object.m ...

How to activate a button only if the specified conditions are met using VueJS 3

I'm currently facing challenges while working on a form to enable a button when certain conditions are met. The form I created includes fields for name, phone number, options, and a message. Once all requirements are filled, I aim to re-enable the di ...

Accessing WordPress without logging in triggers Ajax to retrieve full page content

Currently, I am implementing ajax to increment the click count on a post (post_meta). However, I've encountered an issue where if a user is not logged in on Wordpress, the ajax response returns the entire page content instead of the desired output. I ...

Issue with function not getting triggered upon ng-click event binding

Having trouble getting a button to call the getFilteredRows() function in my MVC app's view and controller. I've tried various combinations, but the button just won't trigger the function. Can anyone help me figure out why? @using ProjectEx ...

Where should I set a value to ensure all listeners are triggered?

In my AngularJS view, I have a dropdown that triggers a function when the color is changed: <select ng-change="shop.updateSizes()" ng-model="shop.color" ng-options="color.name for color in COLORS"></select> The updateSizes method in my contro ...

Transforming a Java Array or Collection into a JSON array

After running my Java code, the returned Collection (ArrayList) produces JSON through JAXB that looks like: {"todo":[{"name":"CAMPBELL","sales":"3","time":"1331662363931"}, {"name":"FRESNO","sales":"2","time":"1331662363931"}]} However, I am wondering if ...

Transmitting JSON information to google form utilizing a textarea and select field

I have developed an application that uses ajax to send json data to a Google form. However, I am encountering difficulties in sending all the desired data, specifically content within a textarea and select tag. To work around this issue, I have hidden some ...

Troubleshooting: Unable to trigger click event on Vuejs component

Working with Vuejs and Vuikit components, I have set up the following structure: <template> <div class="uk-scope"> <vk-modal :show="isShow" v-if="config"> <vk-modal-close @click="alert('hello!')" large& ...

Issue encountered while retrieving JWT

Currently, I am tackling the challenge of implementing JWT authentication using Angular and Java Jersey. I have successfully managed to send the JWT token from the server to the client, which can be observed as a POST response with a status code of 200 in ...

The instantiation of the cloudinary module failed because of an error with the injector

I am currently developing a MEAN application based on the template provided by Linnovate. You can find the template at https://github.com/linnovate/mean My goal is to integrate a module called Cloudinary into my application. To achieve this, I followed th ...