Posted in Javascript onSeptember 11, 2013
.net代码
<system.webServer> ...... .... <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Max-Age" value="3600" /> <add name="Access-Control-Allow-Headers" value="Content-Type, Accept, MaxDataServiceVersion" /> <add name="Access-Control-Allow-Methods" value="PUT, POST, GET, DELETE, MERGE, OPTIONS" /> </customHeaders> </httpProtocol> </system.webServer>
Jquery客户端测试代码
<script type="text/javascript"> $(document).ready(function () { $(":button").on("click", function(event){ //alert( $(this).attr('value')); var url = "http://localhost:2401/ApplicationData.svc/Records"; $.getJSON(url, function (data) { var items = []; var values = data.value; $.each(values, function (key, val) { items.push('<li id="' + key + '">' + val.Name + '</li>'); }); $('<ul/>', { 'class': 'my-new-list', html: items.join('') }).appendTo('#mylist'); }); }); }); </script>
Jquery 跨域访问 Lightswitch OData Service的方法
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@