Click here to Skip to main content
14,929,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

How to call a MVC4 web api restful services using js?. I hosted the service in iis 7. I tried with the following code.


JavaScript
<script>
       $(function () {
           debugger;
           $.ajax({
               url: 'http://172.16.0.110:80/vam/api/Asset/GetAllAssets',
               data: '{"logInInfo":{"UserName":"eisg","Password":"M00s3h3ad"},"lastAssetIDInternal":"","lastSyncDate":"","startSyncDate":"" }',
               type: 'POST',
               dataType: 'json',
               contentType: 'application/json',

               fail: function (data) {
                   alert("aa");
                   alert("a");
               }
           });
       });
   </script>


........................
Posted
Updated 10-Oct-12 0:05am
v4

1 solution

This looks like a cross domain ajax call. That can't be done.
You can only do this if your html file which contains the javascript is also hosted on;

[^]
   

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