Is it possible for me to submit the below POST code to a different domain?

Can a JavaScript HTTP POST request be made to any domain?

Javascript

var xhr = new XMLHttpRequest();

xhr.open("POST", 'URL link', true);

// Include proper header information with the request

xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

xhr.onreadystatechange = function() { // Execute a function when the state changes.

if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {

    // Request completed. Perform processing here.

 }
 }

xhr.send("foo=bar&lorem=ipsum");

// xhr.send(new Int8Array());

// xhr.send(document);

and I want it to be displayed on the screen. Is this achievable?

Answer №1

Absolutely, you can send a request to any domain as long as that specific domain permits the request and the server enables CORS (Cross-Origin Resource Sharing). If you anticipate receiving a response, CORS is essential for sharing resources between different origins.

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

Updating multiple records in Node.js with mongoose using a file as the source of data

I have a CSV file that contains my data, and I am looking to perform a bulk add/update operation. exports.add_questions_from_file = function (file_path, surveyid, callback) { var U = [{}]; fs.readFile(file_path, 'utf8', function(err, dat ...

Looking for assistance with jQuery navigation - struggling with positioning and accordion functionality

The sidebar navigation on this page: needs some attention. I have identified a few issues that need resolution and would appreciate some assistance: The accordion function is working correctly, but the single line item links (those that do not accord ...

Building Firestore subcollections with the latest WebSDK 9: A step-by-step guide

I'm looking to create a subcollection within my document using the webSDK 9, specifically the tree-shakable SDK. While I have come across some solutions, they all seem to be outdated and reliant on the old sdk. Just for context, I am working with Ne ...

Utilize a for loop within a query to showcase a modal popup

I have a specific requirement: I want to display a modal popup window based on a for loop using jQuery. I have attempted the following approach, where I want the modal popup to be displayed based on the value of a flag. For example, if the Flag value is 3, ...

Easily transfer files from your browser application to your Windows applications such as Outlook or printer queues using a simple drag and

I am attempting to transfer a downloaded file from a web browser to a Windows application (such as Outlook or a printer queue) by dragging and dropping. While I can successfully drop the file onto the desktop or any other file explorer location, I face iss ...

Forcing a property binding update in Angular 2

Take a look at this particular component import {Component} from 'angular2/core' @Component({ selector: 'my-app', providers: [], template: ` <div> <h3>Input with two decimals</h3> <input type ...

Tips for including a DOCTYPE declaration when generating an XML document with the "xmlbuilder" npm library

Is it possible to include a !DOCTYPE declaration in an XML file while using the 'xmlbuilder' package? I want to add something similar to the following: <!DOCTYPE IAD.IF.ESTATE.FORRENT SYSTEM "http://www.finn.no/dtd/IADIF-estateforrent71.dtd" ...

The Sizzle.js error, "Uncaught TypeError: undefined (reading 'expr')," is causing some trouble

$.expr[':'].containsCaseInsensitive = function (n, i, m) { return jQuery(n).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0; }; .expr is not recognized. To ensure it's defined, I included a CDN link below: <script src=&qu ...

Sliding content with the grace of a visual journey

I'm currently working on a content slider that is very similar to this one. My goal is to make it rotate automatically, but I've been struggling to get it to work. I've attempted various methods, including triggering a click event on the lin ...

When using React, appending a React Link tag to an existing list item may result in the addition of two objects instead of the desired

Trying to create a loop that checks if an object's date matches with a date on a calendar. If it does, I want to add a React Link tag to the respective li element. The loop logic works well, but the issue is when appending the Link tag using createTex ...

Storing JSON data in an array is a simple process that involves converting

Currently, I am working on implementing dependent dropdowns using JavaScript. The dropdowns include country, state, and city, with the data sourced from the JSON data provided below. My goal is to organize the data in such a way that countries are stored ...

The constricted styles are causing the whole page to bounce (scroll) up and down

On my SPA frontend, I have a parent div with a height of 580 containing 9 smaller divs (about 190px in height each). The parent div has an overflow set to hidden so that only 3 elements are visible at one time. Every 5 seconds, I change the styles by addin ...

Submitting Forms Using Ajax and PHP

Here is the HTML page along with a PHP code snippet that I am using for testing form submission via AJAX. HTML PAGE: $('#but1').click(function(){ $('#frm1').submit(function(){ var dataString = $(this).serializeArray(); ...

Steps for Setting up PHPmailer with Ajax Form Submission

I'm facing an issue with a website server where I've set up this contact form (which works on other hosting) but seems to be malfunctioning on this new hosting. The Support Center advised me to use the phpmailer class, but I'm unsure of how ...

Express JS with multer is unable to process multiple file uploads, resulting in an empty array being

As I develop an app on Glitch with express js, the functionality requires users to upload multiple files. Here is the code snippet that I am using: var express = require('express'); var cors= require('cors'); var bodyParser= requir ...

Create a captivating sliding effect on Windows 8 using a combination of CSS and JavaScript

I believe that using css3 alone can achieve this effect, but I'm struggling with understanding properties like 'ease' in css3. This is the progress I have made so far: http://jsfiddle.net/kwgy9/1/ The word 'nike' should slide to ...

Submit a Bootstrap modal with AJAX and receive blank $_POST data

After setting up my modal form with pre-defined data, I encountered an issue when trying to submit it with ajax. The form.php script was receiving an empty $_POST array even though the submit button was being clicked. What could be causing this problem? & ...

The multiplayer game is experiencing significant delays due to issues with the websocket server

While developing a multiplayer game, I have implemented a WebSocket Server to facilitate communication between clients. However, I am experiencing sporadic delays in message delivery from the server to the client. These delays can be significant, sometimes ...

The Ajax functionality seems to be malfunctioning when attempting to call a

Required Tasks : I have successfully developed an HTML page with the functionality to store a group of form fields into a separate file. Utilizing the Ajax function (AjaxLoad), I am able to send data to file.php and save it successfully. Although I ...

Implementing the Facebook like button using JavaScript with XML and XFBML

Describing the issue at hand: Whenever I try to load a Facebook XML tag (shown below) on a page loaded with Ajax, it does not display properly. The table2.php page is supposed to be loaded by Ajax within the following div: <div id="update_div">< ...