从另一个jquery调用响应为JSON数据的函数并返回响应
我想以JSON格式将数据库查询结果传递给jquery,为此我想到了这一点 第一个函数将从某个c#函数获取数据,然后将该数据作为输入传递给另一个jquery,以便在webservice上进行处理 我对这件事不熟悉。。谁能帮帮我吗 第一个功能:从另一个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",
<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
}
});
}
});