How to natively enable JSONP for existing WCF service?

前端 未结 2 350
天命终不由人
天命终不由人 2020-11-30 11:37

I have a an existing service like the below method:

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[Servic         


        
2条回答
  •  萌比男神i
    2020-11-30 12:30

    The new JSONP feature is exposed via the WebHttpBinding. The configuration for the CustomersService would looks like this:

     
        
          
        
      
      
        
          
        
      
    

    Consuming JSONP with jQuery

     // Get the JsonP data
     $.getJSON('http://localhost:65025/CustomersService.svc/GetCustomers?callback=?', null, function (customers) {
          alert('Received ' + customers.length + ' Customers');
     });
    

提交回复
热议问题