How do I solve the CORS problem? » minor.html
1 |
<script type="text/javascript"> |
---|---|
2 |
function getValue(){ |
3 |
$.ajax({ |
4 |
type : "GET", |
5 |
url : "http://192.168.0.97:3000", |
6 |
dataType : "application/xml", |
7 |
//dataType : "jsonp",
|
8 |
//dataType : "text",
|
9 |
headers : { 'Accept' : 'application/xml', |
10 |
'Access-Control-Allow-Origin' : '*', |
11 |
'X-M2M-RI' : '12345', |
12 |
'X-M2M-Origin' : 'Origin', |
13 |
'uKey' : 'WUsrcUZGeDlJSHlrTkdOQ3pPZUt0dWtBbHc3L0JDdi9Xa3N1ZTJjVXVYR2dGdkduNGhWd3VJc0xwVU9mUXc3ag==' }, |
14 |
error:function(request, status, error){ |
15 |
alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error); |
16 |
},
|
17 |
success : function(data) { |
18 |
console.log(data); |
19 |
}
|
20 |
})
|
21 |
}
|
22 |
|
23 |
function autoFunc(){ |
24 |
getValue(); |
25 |
/*
|
26 |
setInterval(function () {
|
27 |
getValue();
|
28 |
}, 5000);
|
29 |
*/
|
30 |
}
|
31 |
|
32 |
document.addEventListener("DOMContentLoaded", function(){ |
33 |
autoFunc(); |
34 |
});
|
35 |
</script>
|
- « Previous
- 1
- 2
- Next »