0

I've been trying to get data from my ASP WebApi but it is not showing any results, it always fails.

my ASP project is already published on a hosting server, im using the link from my mobile device(Windows Phone) to request data and its working very good. but when I try to use Jquery from my PC (Not in the same project)

it returns nothing.

this is my controller

[AcceptVerbs(HttpVerbs.Get)]
 public JsonResult GetTestData()
    {
        string[] arr = { "val1", "val2", "val3" };
        return new JsonResult() { Data = arr, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
    }

and my Jquery function

$("button").click(function(){
$.getJSON("http://myurl.com/api/GetTestData",function(result){
 $.each(result, function(i, field){
   $("div").append(field + " ");
  });
 });
});

I've been searching and found nothing

some people used Json(arr), and I cant find the Json class

Im new to ASP MVC.

Ibraheem Al-Saady
  • 854
  • 3
  • 14
  • 30

0 Answers0