ASP.NET MVC显示来自json结果的图像

时间:2016-06-22 12:39:24

标签: jquery asp.net asp.net-mvc

图像未显示自json结果值。下面是我的Controller Action和Jquery

public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Please enter a Number");      
        double a = input.nextDouble();
        System.out.print("Please enter a Number ");      
        double b = input.nextDouble();

        if(a==0) {
            System.out.println("can not evaluate expression for a = 0 ");
        } else {
            double division = (b/a);
            double ans = -1 * division ;
            System.out.println(" Expression evaluation is " + ans);
        }

}

});

控制器:

$.post('/User/Comment/',{commentId=Id},function(data){

  $("#cbox").append("<img src="'+data.ImagePath+'" />")

请帮忙解决这个问题。我只需要根据json返回图像路径在剃刀视图上显示图像

1 个答案:

答案 0 :(得分:1)

更改

 $("#cbox").append("<img src='" +data.ImagePath+ "' />")

{{1}}