Jquery前台调去JS的两种方式。

1、首先我的JSON格式为:

{
     totalCount:"1",
     success:true,error:"",
     data:
     [
        {
            DocName:"新建文本文档.txt",
            URL:"2b270311-d1f6-4e09-9f3b-35fe1f62.txt",
            JMBZ:"0",
            CJRID:"1",
            DocType:"txt"
        }
     ]
}

2、调用方式:

$.ajax({
                type: "POST",
                url: targetUrl,
                contentType: "application/json; charset=utf-8",
                success: function (data, status) {
                    alert("返回数据URL:" + data.data.URL);

                },
                error: function (request, status, error) {
                    alert("系统错误,请联系管理员!" + error);
                }
            });

或者用

$.getJSON("url",function(result){
     alert("返回数据URL:" + result.data.URL);

  });

原文地址:https://www.cnblogs.com/BeyondWJsel/p/2474698.html