newklear
Expert Member
- Joined
- Apr 15, 2008
- Messages
- 1,458
Hello All
As title reads, I have a JSON url that I am trying to access using the POST method.
When I run a test using an Html page with supplied url I receive the CORS error, when I change this url to the supplied proxy I receive "NS_ERROR_DOM_BAD_URI: Access to restricted URI denied", which indicates I am still breaking the Same origin policy. I did report this CORS error in the past and was recently given the proxy which was told would bypass this CORS issue.
However when I use The Firefox addon "Poster" for example, I see returning data based on what I send.
Factors:
Are there any workarounds using only Javascript to this please ?
My Current Test Javascript code
Thank You for any input, greatly appreciated.
As title reads, I have a JSON url that I am trying to access using the POST method.
When I run a test using an Html page with supplied url I receive the CORS error, when I change this url to the supplied proxy I receive "NS_ERROR_DOM_BAD_URI: Access to restricted URI denied", which indicates I am still breaking the Same origin policy. I did report this CORS error in the past and was recently given the proxy which was told would bypass this CORS issue.
However when I use The Firefox addon "Poster" for example, I see returning data based on what I send.
Factors:
- Can only make use of Javascript
- No use of JQuery
Are there any workarounds using only Javascript to this please ?
My Current Test Javascript code
Code:
<!DOCTYPE html>
<html>
<script>
//var url = "http://alternate.business.url";
var url = "/SuppliedProxy";
var getJSON = function(url) {
return new Promise(function(resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open('post', url, true);
xhr.responseType = 'json';
xhr.onload = function() {
var status = xhr.status;
if (status == 200) {
resolve(xhr.response);
} else {
reject(status);
}
};
xhr.send();
});
};
//getJSON('url').then(function(data) {
getJSON(url);
'"typeHint":"person",' +
'"firstName":"' + 'TestName' + '"';
console.log(getJSON);
</script>
</html>
Thank You for any input, greatly appreciated.