well guys... i've tried lots fix problem, catching solutions here , in others sites... don't solution problem!
well what's real problem.. it's simple have code:
function refreshradiostats() { jquery.support.cors = true; $.get('http://raphaleao.com/json', function(data){ var templatestats = '<span class="glyphicon glyphicon-music"></span> '+ j_lang[0] + '<marquee><h4><i>'+data.musica_atual+'</i></h4></marquee><br>'+ '<span class="glyphicon glyphicon-headphones"></span> '+j_lang[1]+': <b>'+data.ouvintes_conectados+ '</b><br>'+ '<span class="glyphicon glyphicon-user"></span> '+j_lang[3]+': <b>'+locutor+'</b><br><br>'+ '<button type="button" class="btn btn-info" id="refreshstadistics" style="width:100%"><span class="glyphicon glyphicon-refresh"></span> '+ j_lang[2] +'</button>'; $('#resultse').append(templatestats); },'json'); }
ok, what's problem? problem is: script apparently can't acess website http://raphaleao.com/json , this, doesn't work. problem:
xmlhttprequest cannot load http://raphaleao.com/json. 'access-control-allow-origin' header contains multiple values '*, *', 1 allowed. origin 'stack don't allow me post more 2 links' therefore not allowed access.
the script works, because i've tested other site in json , works perfectly. i've put in web.config:
<httpprotocol> <customheaders> <add name="access-control-allow-origin" value="*" /> </customheaders> </httpprotocol>
and same problem, guys me this?
i've fix well, after try things , @mattferderer opened mind, figured out what's going on this...
first i've removed web.config side , leave header() function. okay first problem fixed (lol);
and than, i've figured out why $.getjson() don't load informations of other website... it's simple, add (at least did in php) this:
header('content-type: text/javascript');
in case, page in format text/html, $.getjson() not able load informations in page!
thanks guys , sorry terrible english!
try removing access-control-allow-origin web.config since problem access-control-allow-origin being used twice. if in response headers shows this:
http/1.1 200 ok content-type: text/html content-encoding: gzip vary: accept-encoding server: microsoft-iis/7.5 x-powered-by: php/5.5.11 access-control-allow-origin: * x-powered-by: asp.net access-control-allow-origin: * date: wed, 06 apr 2016 14:43:54 gmt content-length: 387
Comments
Post a Comment