jquery & ajax 呼叫跨網域 xml 請求 出現 Access-Control-Allow-Origin

使用 jquery & ajax
請求 跨網域頁面時瀏覽器cosole會出現警告

Access-Control-Allow-Origin



此時在提供頁面的端口加上web.config

內容呈現如下重啟即可

<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <system.webServer>
   <httpProtocol>
     <customHeaders>
       <add name="Access-Control-Allow-Origin" value="*" />
     </customHeaders>
   </httpProtocol>
 </system.webServer>
</configuration>

SVG 實作

$(document).ready(function () {

r1();

});

function r1()
{
  var rc = "";
  var x = 0 ;
  var y = 0 ;
     var c1 = "";
     var c2 = "";

     for( i = 0 ; i < 100 ; i++ )
     {

y = (i%6)*36 ;

z = Math.floor((Math.random() * 10) + 1)

if( z%3==0){c1 = "red"; c2="莊";}
if( z%3==1){c1 = "blue";c2="閒";}
if( z%3==2){c1 = "green";c2="和";}


rc +="<svg  id = 'svg1'  style='left: "+ x +"px; top:"+ y +"px; position: absolute ; z-index: 999;visibility:visible'>";
rc +="<circle cx='20' cy='20' r='18' stroke='green' stroke-width='0' fill="+ c1 +" />";
rc+="<text style='fill:white;'font-size='24' font-family='SimHei' x='9' y='28' width='0' height='0'>"+c2+"</text>";
rc+="</svg>";


if( (i+1)%6 == 0 )x+=36;
}

$('#roadcontent').append(rc);





<div id= "roadcontent"></div>


https://jsfiddle.net/c9rmzb8h/#