I am creating a website with HTML and JavaScript that relies on the data of an XML file hosted on a separate domain.
I can achieve this with jQuery-Ajax if the XML is in the same domain as my HTML page, but I cannot find a solution when the file is on a different domain.
Any ideea of how can i read a file from different domain using JavaScript in html page (Not server side)?
Access an XML file from different domain in JS
-
- Posts:107
Access an XML file from different domain in JS
MarPlo
Posts:186
Try using the the fetch api.
I thing you don't need to serialize the xml, you should just be able to put it directly... but not sure.
Code: Select all
fetch('//example.com/file_address')
.then( response => response.text() )
.then( response => {
//response is a string containing xml...
document.getElementById('elm_id').innerHTML = response;
})
.catch( console.error );
Similar Topics
- GET_id not working in UnLink (delete file)
PHP - MySQL First post
I searching for an hour for a solution; unlink seems not to work with GET idLast post
<?php
$id = (int) $_GET ;
echo $_GET ;
$file = fopen( '.$_GET...
Here is an answer `o god after 2 hours shame on me for this one`
<?php
$file_pointer = $_GET .'.txt';
if (!unlink($file_pointer)) {
echo (...