Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I got stuck with the cross domain task, where i have a url of a xml file which consist of some data . My task is to fetch the data from the url i.e, xml file which should be displayed in a drop down list .And the problem is ,the program which i have posted here allows the url which consist json format file but its not responding for the xml file .So, i will be thankful if some one help me with this...


---index.html---


XML
<!DOCTYPE html>
<html ng-app="App">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.min.js">   </script>
  <script src="script.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
  </head>
  <body>
  <div ng-controller="AppCtrl">
    <h1>{{val}}</h1>

   <select ng-options="p.ProductName for p in Product" ng-model="blah"></select>
</div>
</body>
</html>





---script.js---



// Code goes here
// Code goes here
var App = angular.module('App',[])
          .controller('AppCtrl', function($scope, AppFact) {
            $scope.val = "Testing the Page For CallsBacks";
            AppFact.getData(function(Product) {
              $scope.Product = Product;
            });
          })
          .factory('AppFact', function($http) {
           return {
             getData: function(successcb) {
            //var url = 'http://filltext.com/?callback=JSON_CALLBACK&rows=10&fname={firstName}&lname={lastName}';
           var url = 'http://xxxxxxxx';
            $http.jsonp(url).
            success(function(Product,status,headers,config) {
              alert(Product);
              console.warn(Product);
              successcb(Product);
            }).
            error(function(Product, status,headers, config) {
              //alert(status);
              //alert("Status is " + status);

            });
             }
                        };
          });



//var url = 'http://filltext.com/?callback=JSON_CALLBACK&rows=10&fname={firstName}&lname={lastName}'this is a json url which works fine .

And the other url is what i needed to be worked and it consist of xml file ,And i'm not suppose to display the original url so i have given as var url = 'http://xxxxxxxx' . Plz help me wit this ....

Here is my plunker:http://plnkr.co/edit/qq8sELDdZZB5QKe1Pj3T?p=preview
Posted
Updated 21-May-15 0:41am
v2
Comments
Afzaal Ahmad Zeeshan 21-May-15 7:09am    
Is CORS enabled?
Anil chean 21-May-15 9:28am    
Yes..

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