Page Method(使用jQuery调用)返回页面的全部内容,而不返回method的值. [英] Page Method (calling with jQuery) returns page's whole content, not return value of method.

查看:108
本文介绍了Page Method(使用jQuery调用)返回页面的全部内容,而不返回method的值.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我们正在使用jquery发送ajax请求,但每次都会返回其页面的内容.
我们正在使用此代码.
使用.NET Framework版本2的服务器

Hi we are using jquery to sending ajax requests but its returns page''s content everytime.
we are using this code.
Server using .NET Framework version 2

$.ajax({
    type: "POST",
    url: "ajaxPage.aspx/testMethod",
    data: "{test:'test'}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (result) {
        $("#span_result").html(result.d).fadeIn();
    },
    error: function (msg) {
         $("#span_result").hide();
    }
}); 





//ajaxPage.aspx.cs
[System.Web.Services.WebMethod]
public static string testMethod(string test)
{
     return test;
}

推荐答案

.ajax({ 类型:" , 网址:" , 数据:" , contentType:" , dataType:" , 成功:功能(结果){
.ajax({ type: "POST", url: "ajaxPage.aspx/testMethod", data: "{test:'test'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (result) {


(" #span_result").html(result.d).fadeIn(); }, 错误:函数(msg){
("#span_result").html(result.d).fadeIn(); }, error: function (msg) {


(" #span_result").hide(); } });
("#span_result").hide(); } });





//ajaxPage.aspx.cs
[System.Web.Services.WebMethod]
public static string testMethod(string test)
{
     return test;
}


这篇关于Page Method(使用jQuery调用)返回页面的全部内容,而不返回method的值.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆