0

I am new to AngularJS, i am trying to get the data using REST api url and i am trying to pass the URL to angularjs and display the data in HTML. But it shows Internal Server Error. Please find the screenshot of error and rest URL data

enter image description here

enter image description here

enter image description here

Here is my HTML,

<html ng-app="myApp" ng-controller="myCtrl">

<head>

  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js">
  </script>
  <script>
    var app = angular.module('myApp', []);
    app.controller('myCtrl', function($scope, $http) {
      $http({
        method: "GET",
        url: "http://localhost:8080/WebApplication1/webresources/rest.employee/Show/1"
      }).then(function mySucces(response) {
        $scope.myWelcome = response.data;
      }, function myError(response) {
        $scope.myWelcome = response.statusText;
      });
    });
  </script>
</head>

<body>
  {{myWelcome}}
</body>

</html>
4
  • what error you are seeing in console of debugger/developer tool in browser ? Commented Jul 31, 2016 at 16:26
  • I have included another screenshot of console error... Commented Jul 31, 2016 at 16:28
  • Then you should check at the server side what's going on there Commented Jul 31, 2016 at 16:32
  • It's hard to determine what exactly is going on with only the information you have provided. I am inclined to believe that this error is happening server-side. Yes, you are pinging the server with a request but if you are hitting your target endpoint with the proper payload and your server is giving you back a 500 then your server isn't configured properly or your server is expecting an explicit payload that you aren't providing. Please debug your server side code and reply with what you are observing. Commented Jul 31, 2016 at 17:02

2 Answers 2

1

This may be because the response content-type is xml. Try angular-xml or this gist

Sign up to request clarification or add additional context in comments.

Comments

0

enter image description here

enter image description here

Step 1: Right Click on chrome icon then Select Property Menu

Step 2: Select Shortcut Tab. then below in Target text box already some path will be there. example: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

Don't change the path add --user-data-dir="C:/Chrome" --disable-web-security this text at the end of the path.

Example: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir="C:/Chrome" --disable-web-security

Step3: Then Click Ok Button

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.