2016-11-05 5 views
0

私はasp.netで、コールWebサービス(angularjs)

を私は私のjavascriptファイルからWebサービスを呼び出すために必要のあるMVC5でWebアプリを作成しています私は

のように呼び出すために使用
$http.get('/welcome.asmx/welcomegrid', { 
     params: { 
     } 
    }) 

が、MVC5で、私が

$http.get("http://localhost:50353/Models/welcome.asmx/welcomegrid", { 
     params: 
     { 

     } 
    }) 
もこれを試してみました私は

Request format is unrecognized for URL unexpectedly ending in '/welcomegrid' 

をエラー表示されます

しかし、私はあなたが次のコードを使用することができ、より多くの助けConsuming Rest API Calls in AngularJS using $http Service

答えて

0

に直面しています: -

$http.get("http://localhost:50353/Models/welcome.asmx/welcomegrid") 
.then(function(response){ 
    //This function will be executed when the request was completed successfully 
}, function(response){ 
    //This function will be executed when the request was not successful. 
}) 

ここではresponse.dataにはサーバーからのデータが含まれます。 このレスポンスオブジェクトは、さまざまな属性を持っている、あなたは、このリンクをより多くのチェックアウトすることができます: - https://docs.angularjs.org/api/ng/service/ $ HTTP

0

ため

$scope.getData = function() { 
     $scope.loading = true; 
     $http.get("http://jsonplaceholder.typicode.com/posts/1") 
     .then(function(response){ 
      $scope.details = response.data; 
      $scope.loading = false; 
     }); 
    } 

をあなたはangularjsコードの下に使用することができ、同じエラー

0

あなたは、私は非常に追加することにより、サーバー側でそれを包むお勧め古い学校のWebサービスと通信しようとしているので、それはサービス参照として。そうすることで、AngularJSアプリケーションを含む今日のクライアントサイドアプリケーションのほとんどが通信したいJSONサービスとして公開することができます。詳細についてはhttps://msdn.microsoft.com/en-us/library/bb628649.aspx

関連する問題