如何在dnn中的ascx页面中调用web serivce方法 [英] How to call web serivce method in ascx page in dnn
本文介绍了如何在dnn中的ascx页面中调用web serivce方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们必须在ascx模块上使用web服务方法,使用jquery是行不通的。请任何人尽快解释
我尝试过:
asmx page :
We have to use web service method on ascx module using jquery is not working. Please anyone explain ASAP
What I have tried:
asmx page:
[WebMethod]
public Employee GetEmployeeDetail()
{
Employee objEmp = new Employee();
objEmp.EmpFirstName = "Tech";
objEmp.EmpLastName = "Illumination";
return objEmp;
}
public class Employee
{
public string EmpFirstName { get; set; }
public string EmpLastName { get; set; }
}
ascx页面:
ascx page:
$('#btnCallService').click(function () {
$.ajax({
type: 'POST',
url: 'wsKamName.asmx/GetEmployeeDetail',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function (response) {
$('#lblData').html(JSON.stringify(response));
},
error: function (error) {
console.log(error);
}
});
});
推荐答案
(' #btnCallService')。click( function (){
('#btnCallService').click(function () {
.ajax( {
类型:' POST',
url:' wsKamName.asmx / GetEmployeeDetail',
dataType:' json',
contentType:' application / json; charset = utf-8',
成功: function (响应){
.ajax({ type: 'POST', url: 'wsKamName.asmx/GetEmployeeDetail', dataType: 'json', contentType: 'application/json; charset=utf-8', success: function (response) {
(' #lblData')。html( JSON .stringify(response));
},
错误: f unction (错误){
console .log(错误);
}
});
});
('#lblData').html(JSON.stringify(response)); }, error: function (error) { console.log(error); } }); });
这篇关于如何在dnn中的ascx页面中调用web serivce方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文