Question

I am new in phoneGap. I have a server that`s written in web API 2. I am trying to make a call to my web API 2 server from phonegap. My Web Api 2 Server Support CROSS. I tested it from fiddler2 and couple of browser and they works fine. But unable to make a get request from PhoneGap.

My HTML is :

!DOCTYPE html>
<html lang="en" ng-app="taxiConceptApp">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
    <link rel="stylesheet" type="text/css" href="css/index.css" />
    <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet" />
    <link href="css/bootstrap-theme.min.css" type="text/css" rel="stylesheet" />
    <link href="css/app.css" rel="stylesheet" />
    <title>Hello World</title>


</head>
<body>
    <script type="text/javascript" src="js/jquery-2.1.0.min.js"></script>
    <!--<div id="contnr" ng-view>
    </div>-->

    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
    <script type="text/javascript">
        app.initialize();

        $.get('https://www.google.co.uk/', function (data) {
            alert(data);
        });
        $.get('http://localhost:15229/api/values', function (data) {
            alert(data);
        });

    </script>
</body>

</html>

this code is successfully get html from google.

$.get('https://www.google.co.uk/', function (data) {
                alert(data);
            });

but this is not.

$.get('http://localhost:15229/api/values', function (data) {
                alert(data);
            });

Here is my Fiddler2 output :

enter image description here

Web Api Server :

public class ValuesController : ApiController
  {
     // GET api/values
     public IEnumerable<string> Get()
     {
        return new string[] { "value1", "value2" };
     }
  }

I am using :

  • Visual Studio 2013 ultimate with windows Phone 8 SDK
  • PhoneGap 2.9.1

is it occurs for windows Phone emulator or for my code?

I already spend five days for it.

Thanks in advance.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top