[英]Call function from class in c# using jquery ajax
I have been able to call the function using ajax using following code 我已经能够使用以下代码使用ajax调用该函数
function AjaxCall() {
$.ajax(
{
type: 'POST',
contentType: "application/json; charset=utf-8",
url: 'Default.aspx/Server_HelloWorld',
datatype: 'json',
success: function (result) { alert(result.d); }
})
}
using System.Web.Services;
using System.Web.Script.Services;
aspx.cs Ajax Webmethod, aspx.cs Ajax Webmethod,
[WebMethod]
public String Server_HelloWorld()
{
return "Hello, How are you?";
}
But if i don't have any .aspx
page, i have only .html page with a class say myfunclass.cs
. 但是,如果我没有任何
.aspx
页面,那么我只有.html页面,其类为myfunclass.cs
。 How do i call the same function from here. 我如何从这里调用相同的功能。 I have tried but fail
我已经尝试过但是失败了
$.ajax(
{
type: 'POST',
contentType: "application/json; charset=utf-8",
url: 'myfunclass.cs/Server_HelloWorld',
datatype: 'json',
success: function (result) { alert(result.d); }
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.