Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从另一个jquery调用响应为JSON数据的函数并返回响应_Jquery_Ajax_Json.net - Fatal编程技术网

从另一个jquery调用响应为JSON数据的函数并返回响应

从另一个jquery调用响应为JSON数据的函数并返回响应,jquery,ajax,json.net,Jquery,Ajax,Json.net,我想以JSON格式将数据库查询结果传递给jquery,为此我想到了这一点 第一个函数将从某个c#函数获取数据,然后将该数据作为输入传递给另一个jquery,以便在webservice上进行处理 我对这件事不熟悉。。谁能帮帮我吗 第一个功能: <script type="text/javascript"> var Result1; var Result2; function btnJquery_Click() { $.ajax({ type: "POST",

我想以JSON格式将数据库查询结果传递给jquery,为此我想到了这一点 第一个函数将从某个c#函数获取数据,然后将该数据作为输入传递给另一个jquery,以便在webservice上进行处理

我对这件事不熟悉。。谁能帮帮我吗

第一个功能:

 <script type="text/javascript">

var Result1;
var Result2;

function btnJquery_Click() {
    $.ajax({ type: "POST",
        url: "Default.asmx/GetData", // this will get data from c# function
        data: {},
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function CallanotherFunction (response) { Result1= JSON.parse(response);} 
    }); 

function CallanotherFunction () {
    $.ajax({ type: "POST",
        url: "Default.asmx/GetData", // this will get data from c# function
        data: Result1,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function CallanotherFunction (response) {Result2= JSON.parse(response); } 
    }); 

     }
</script>

var结果1;
var结果2;
函数btnJquery\u Click(){
$.ajax({type:“POST”,
url:“Default.asmx/GetData”//这将从c#函数获取数据
数据:{},
contentType:“应用程序/json;字符集=utf-8”,
数据类型:“json”,
成功:函数CallanotherFunction(response){Result1=JSON.parse(response);}
}); 
函数CallanotherFunction(){
$.ajax({type:“POST”,
url:“Default.asmx/GetData”//这将从c#函数获取数据
资料:结果1,
contentType:“应用程序/json;字符集=utf-8”,
数据类型:“json”,
成功:函数CallanotherFunction(response){Result2=JSON.parse(response);}
}); 
}
这只是虚构的代码;无法使用..请帮助我编写代码

尝试使用
.done()

function btnJquery_Click() {
    $.ajax({ type: "POST",
        url: "Default.asmx/GetData", // this will get data from c# function
        data: {},
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response) { 
        Result1= JSON.parse(response);

        }).done(function(Result1){
         CallanotherFunction (Result1)
        }) 
    }); 
$.ajax({
    type: "POST",
    url: "Default.asmx/GetData", // this will get data from c# function
    data: {},
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (data) {
        Result1 = JSON.parse(data); //1st ajax data
        $.ajax({
            type: "POST",
            url: "Default.asmx/GetData", // this will get data from c# function
            data: Result1, //used 1st ajax data
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (response) {
                Result2 = JSON.parse(response);//here 2nd ajax data based on first ajax call
            }
        });
    }
});