I am trying to get a value from this URL (returns pure XML):
And I want to store this value in this element on a separate site:
<div id="result" style="color:red"></div>
Every javascript or jquery attempt I try results in some "access-control-origin" error, which I understand to a point but I can't do anything about the remote server. I need a quick front-end solution.
Note: There is another format I can return the data in - JSON. But I have had similar issues above in trying to get that data as well.
Because you are trying to make cross domain request and because server only allow jsonp for cross domain request, then use jsonp. For example:
$.ajax({
url: 'http://demo.piwik.org/?module=API&method=VisitsSummary.getUniqueVisitors&idSite=7&period=day&date=today&format=json&token_auth=anonymous',
dataType: 'jsonp'
}).done(function(data){
$('#result').html(data.value);
});