DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> jQuery入門知識 >> JQuery特效代碼 >> Jquery 跨域訪問 Lightswitch OData Service的方法
Jquery 跨域訪問 Lightswitch OData Service的方法
編輯:JQuery特效代碼     

.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>

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved