Evolution of the same-origin policy in relation to XMLHttpRequest requests throughout history

About four years ago, I wrote some JavaScript code that included an XMLHttpRequest request. It originally looked like this:

xmlhttp.open('GET', 'http://www.example.com/script.php?arg=val&sid=' + Math.random(),true) ;

However, since then the code has stopped working. I then made a change to the request to look like this:

xmlhttp.open('GET', 'script.php?arg=val&sid=' + Math.random(),true) ;

This modification fixed the issue and everything now works as expected on all major browsers.

My question is, has the same origin policy for Chrome and Firefox changed over the past four years in a way that required this XMLHttpRequest to be fixed? I recall that it used to work initially, but I am unable to go back in time to verify. I have not been able to find any documentation online that indicates a change in the same origin policy. I apologize if this is not the right forum for this question, but I am eager to understand why this behavior changed. A simple response like "Yes, there was a change" or "No, this should never have worked in the first place" would be helpful.

Answer №1

To ensure the same origin, the domain must match precisely, along with the protocol (e.g. http or https), and the port (if indicated). It's possible that your webpage has switched to https or started using a custom port?

For instance, starting from

https://www.samplewebsite.com/index.html
, it would not be possible to make an ajax call to
http://www.samplewebsite.com/script.php
.

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

Creating dynamic web pages with jQuery is a simple and effective

I am currently using jQuery to create HTML elements with specific classes and then append them together. However, the code I have written is not adding the generated HTML to the container as expected. There are no errors being produced but the HTML is not ...

Different ways to modify the CSS file of the bx-slider plugin for multiple sliders within a single webpage

Currently in the process of building a website using bx slider. I am looking to incorporate three sliders onto a single page for sliding HTML content. Initially, I added a bx slider to the page and customized it using CSS. I made modifications within jqu ...

Tailwind does not display font sizes using random values

I am attempting to adjust the size of a span element based on a number from a variable: export default async function Tags() { const tags = await getTags(); return ( <div> <Suspense> <div className="flex flex-wrap ...

Preventing the window from resizing while an AJAX query is in progress

I have a script in jQuery that serves as a search tool and also has the capability to resize an element to match the screen height minus 40 pixels whenever the window is resized. However, I am looking for a way to turn off the resizing feature when a searc ...

When using the `Node fs.readstream()` function, the output includes `<Buffer 3c 3f 78 6d 6c ...>`, which is not in a readable

Handling a large XML file (~1.5gb) in Node Js by streaming it to process data in chunks has proven challenging due to the complexity of the documentation. A simple code snippet I am currently using is: var fs = require('fs'); var stream = fs.c ...

Tips for filtering only alpha versions, such as those labeled 1.0.0-alpha.*

Is it possible to specifically target -alpha versions of a package using semver and NPM? The common approaches like using 1.0.0-alpha.x or * do not seem to work as expected due to how the version elements are interpreted. The usage of ~1.0.0-alpha also do ...

Troubleshooting issue with ng-change function in AngularJS

I have been working on developing a web application that includes two dropdown lists. My goal is to update the data in dropdown list 2 whenever there is a change in dropdown list 1. <tr> <td> State </td> <td> ...

Tips for obtaining the iframe #document with cheeriojs?

I've been struggling to scrape the anime videos page [jkanime], specifically with extracting the mp4 video formats embedded in an iframe #document. Despite trying to use cheerio for querying, I've only managed to retrieve src links from Facebook ...

Is there a way to incorporate the 'id' in my textbox within an ajax request?

I have a table that I accessed through ajax, displaying various items with quantity, price, subtotal, and exchange options. Name Qty Price subtotal exchange 123 Pepsi 2 5.000 10.000 | [txtbox1] | [button] 221 To ...

How to highlight all the text within a 'pre code block' when double-clicked using JavaScript

Is there a way to make code blocks on my blog automatically selected when double-clicked without using jQuery? Here is the code I have so far: I apologize if this is a silly question, I am still learning! <script type="text/javascript" src="https://c ...

Adding and removing content through ajax operations

Currently, I am focused on implementing basic functionality for insert, add, delete, and update operations using ajax. I have made some progress with the functionality but my goal is to incorporate all features in a grid format. To achieve this, I have ...

Vue component lifecycle hook to fetch data from Firebase

Looking for a solution with Vue 2 component that utilizes Vuefire to connect declaratively with a Firebase real-time database: import { db } from '../firebase/db' export default { data: () => ({ cats: [] }), firebase: { ...

How can I retrieve the top-level key based on a value within a JSON object nested in JavaScript?

If I have the value Africola for key name in the following nested JSON structure, how can I retrieve its corresponding upper-level key 'barID1' using JavaScript? { "barID1": { "address": "4 East Terrace, Sydney NSW 2000", "appStoreURL" ...

Execute the strace command using the child_process module in Node.js

Having received no answers and being unsatisfied with the previous approach, I am now attempting a different method to monitor the output of a program that is currently running. Inspired by a thread on Unix Stack Exchange, the goal is simply to retrieve th ...

How to Retrieve URL Data in Spring MVC with AJAX / JSON When Loading a New Page

Utilizing Spring MVC in the backend and HTML, AJAX, JSON with jQuery in the frontend, I have a two-page setup. The initial page is named: http://localhost:8080/myproject/start Here, I set up data initialization and execute AJAX/JSON requests using jQuery: ...

Is it possible to disable a monitor using ajax and receive a confirmation message in return?

I am currently developing a web application designed to be used on a kiosk with a touch screen interface. Our goal is to implement the feature of turning off the screen directly from an administrative page, without relying on Windows power management setti ...

Failing to retrieve data from Ajax response

When handling requests in a servlet, the following code snippet processes the request received: Gson gson = new Gson(); JsonObject myObj = new JsonObject(); LoginBean loginInfo = getInfo(userId,userPwd); JsonElement loginObj = gson.toJsonTree(loginInfo) ...

A single element containing two duplicates of identical services

I am encountering an issue with my query builder service in a component where I need to use it twice. Despite trying to inject the service twice, it seems that they just reference each other instead of functioning independently, as shown below: @Component( ...

Parsing URLs using AJAX in Wordpress

Is it possible to extract and manipulate a URL in Wordpress for the purpose of creating a query? For example, if I wanted to display a list of archives in the sidebar using wp_get_archives() through AJAX, how can I utilize Wordpress functions to construct ...

Whenever I try to execute the command `electron .` in the electron-quickstart project, I immediately encounter an error within the

Upon successfully installing Electron, I attempted to run it using "electron" or "electron -v" commands. Unfortunately, I encountered an error while running it on Windows 10. C:\Windows\System32\electron-quick-start>electron -v modu ...