Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Although I am able to display my AngularJS JSON data in chrome, but for some reason I can not display it in firefox.

What I have tried:

I checked firefox console log but it displays me some no helpful logs. I'm pretty sure reading the console log is not the way to troubleshooting this problem.

here is my server side code in c sharp:
C#
public JsonResult getData()
{

    List<SelectListItem> l = new List<SelectListItem>();
    l.Add(new SelectListItem { Text = "a", Value="b" });
    l.Add(new SelectListItem { Text = "c", Value = "d" });

    return Json(l, JsonRequestBehavior.AllowGet);

}


And here is my client side codes:

JavaScript
$http({
    url: "home/getData",
    dataType: 'json',
    method: 'GET',
    headers: {
        "Content-Type": "application/json"
    }
}).then(function success(response) {
    $scope.Details = response.data;
    }, function error(response) {
        $scope.Details = response.statusText;
    })


HTML
<ul>
    <li ng-repeat="x in Details">
        {{x.Text}}
    </li>
</ul>
Posted
Updated 26-Nov-17 0:05am

1 solution

Loading same page with localhost and localhost/Home/Index has different result.
You must set url: "home/getData" or url: "getData" according to displaying address in browser.
 
Share this answer
 
v2

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