简体   繁体   English

JSON在IIS8部署的应用程序上不起作用

[英]JSON Not Working on IIS8 Deployed Application

I have a working MVC5 Web application, when am debugging on VS it works perfectly well and pull all Json formatted files to dropdown box very well. 我有一个可以正常工作的MVC5 Web应用程序,在VS上调试时,它可以很好地运行并将所有Json格式的文件很好地拉到下拉框。

But When I Deployed the application on IIS8 the Json refused to pull to my nested dropdown when choose, So am I missing any configuration for it to work on my localhost(IIS)? 但是,当我在IIS8上部署应用程序时,Json在选择时拒绝拉到嵌套的下拉列表,那么我是否缺少任何配置使其可以在localhost(IIS)上运行? I will really appreciate any help thanks. 非常感谢您的帮助。

I checked on my browser debugger and found out that it returning a 404 Not Found error on the javascript console, But this is the same application that am lunching on VS and it working fine... Please am kind of confuse any help please? 我检查了我的浏览器调试器,发现它在javascript控制台上返回404 Not Found错误,但这是在VS上使用午餐的同一应用程序,并且运行良好。请混淆任何帮助吗?

Try to use relative path on url from where you have called the function through JSON in your view page. 尝试在视图页面中使用通过JSON调用函数的URL上的相对路径。

Like as below: 如下图所示:

var urlRelative = '<%= Url.Action("Action", "Controller") %>';
                $.getJSON(urlRelative, function (sourceData) {
                    var select = $("#SourceInfoComboBox1");
                    select.empty();

                    select.append($('<option/>', {
                        value: null,
                        text: "-Select-"
                    }));


$.each(sourceData, function (index, itemData) {
                    select.append($('<option/>', {
                        value: itemData.Value,
                        text: itemData.Text
                    }));
                });

        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM