ajax > $.getJSON(url,[data],[fn])
ajax > $.ajax(url,[settings]) post的请求加载数据。 api文档http://jquery.cuishifeng.cn/jQuery.Ajax.html
1 $.ajax({ 2 url: "http://localhost:8081/api/interface", 3 type: "POST", 4 data:{ 5 "c": "1", 6 "ch":"appstore", 7 "v":"1.0.0" 8 }, 9 dataType:"json", 10 success: function(msg){ 11 alert( "Data Saved: " + msg ); 12 } 13 });
问题:No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8081' is therefore not allowed access.
应该是无法跨域。
如果把 dataType 改成 JSONP ,则会出现错误
Uncaught SyntaxError: Unexpected token
参考思路:http://kb.cnblogs.com/page/139725/
http://justcoding.iteye.com/blog/1366102/
http://www.cnblogs.com/know/archive/2011/10/09/2204005.html
分析解决:
浙公网安备 33010602011771号