无法在firefox中显示angularjs JSON数据 [英] Can not display angularjs JSON data in firefox

查看:98
本文介绍了无法在firefox中显示angularjs JSON数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

虽然我能够在chrome中显示我的AngularJS JSON数据,但由于某些原因我无法在firefox中显示它。



我有什么尝试过:



我检查了firefox控制台日志,但它显示了一些没有用的日志。我很确定阅读控制台日志不是解决这个问题的方法。



这里是我的服务器端代码c sharp:

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:

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:

$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;
    })







<ul>
    <li ng-repeat="x in Details">
        {{x.Text}}
    </li>
</ul>

推荐答案

http({
url: home / getData
dataType:' json'
方法:' GET'
标题:{
Content-Type < span class =code-string> application / json
}
})。then( function success(response) {
http({ url: "home/getData", dataType: 'json', method: 'GET', headers: { "Content-Type": "application/json" } }).then(function success(response) {


scope.Details = response.data;
}, function 错误(响应){
scope.Details = response.data; }, function error(response) {


scope.Details = response.statusText;
})
scope.Details = response.statusText; })







<ul>
    <li ng-repeat="x in Details">
        {{x.Text}}
    </li>
</ul>


这篇关于无法在firefox中显示angularjs JSON数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆