Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
HTML
<!DOCTYPE html>
<html>
<head>
    <title> </title>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
    <script type="text/javascript">
        var app = angular.module('myApp', []);
        app.controller('myCtrl', function ($scope, $http) {
            //$http.get('http://localhost:24844/SettingsRestService.svc/GetListitems/12')
           $http.get('http://demo3.engquote.co.in/SettingsRestService.svc/GetListitems/12')
        .then(function (response) {
            $scope.Customer = response.data.RESTGetListitemsResult;
        });
        });
    </script>
</head>
<body>
    <div ng-app="myApp" ng-controller="myCtrl">
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>
                        Customer ID
                    </th>
                    <th>
                        Company Name
                    </th>
                    <th>
                        City
                    </th>
                </tr>
            </thead>
            <tr ng-repeat="x in Customer">
                <td>
                    {{x.ListItemID}}
                </td>
                <td>
                    {{x.ListItemDescription}}
                </td>
                <td>
                    {{x.ListGroupID}}
                </td>
            </tr>
        </table>
    </div>
</body>
</html>


What I have tried:

I m trying the above get method using AngularJS...they perfectly work on localhost... and i m host the service in server...the
url: http://demo3.engquote.co.in/SettingsRestService.svc/GetListitems/12

They throw error is: "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://demo3.engquote.co.in/SettingsRestService.svc/GetListitems/12. (Reason: CORS header 'Access-Control-Allow-Origin' does not match 'http://demo3.engquote.co.in, *')."

How to reslove this error...plz help
Posted
v2
Comments
There are ways to enable CORS. Have you tried?
venkatesh (chennai) 4-Sep-16 2:55am    
i m trying to change my web.congif file


they working my localhost....but not work hosting server

1 solution

<system.webserver>
<httpprotocol>
<customheaders>
<add name="Access-Control-Allow-Origin" value="*"></add>
</customheaders>
</httpprotocol>
</system.webserver>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900