呼叫使用jQuery ASP.NET PageMethod的/的WebMethod - 返回整个页面 [英] Call ASP.NET PageMethod/WebMethod with jQuery - returns whole page

查看:134
本文介绍了呼叫使用jQuery ASP.NET PageMethod的/的WebMethod - 返回整个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery的1.3.2,ASP.NET 2.0。要实现AJAX调用一个PageMethod的(的WebMethod)返回完整/整页,而不是只是响应。页面方法断点显示它从来没有击中。我有我的方法[WebMethod]属性,它的的公共静态,返回字符串和不接受任何PARAMS。我甚至尝试添加[ScriptService]在我班上的第一名,看它是否帮助,但事实并非如此。

jQuery 1.3.2, ASP.NET 2.0. Making an AJAX call to a PageMethod (WebMethod) returns the full/whole page instead of just the response. A breakpoint on the page method shows it's never getting hit. I have the [WebMethod] attribute on my method, and it is public static, returns string and accepts no params. I even tried adding [ScriptService] at the top of my class to see if it helped, but it did not.

我已经看到了这个帖子<一个href=\"http://stackoverflow.com/questions/348689/jquery-ajax-with-asp-net-webmethod-returning-entire-page\">http://stackoverflow.com/questions/348689/jquery-ajax-with-asp-net-webmethod-returning-entire-page其中有我相同的症状,但我仍然有一个问题。我读<一个href=\"http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/\">http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/我觉得我这之后的T,但仍没有运气。

I have seen this post http://stackoverflow.com/questions/348689/jquery-ajax-with-asp-net-webmethod-returning-entire-page which had my same symptoms, but I am still having a problem. I read http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/ and I feel like I'm following this to the T, but still no luck.

jQuery的电话我做的是:

The jQuery call I'm making is:

jQuery.ajax({
    type: 'POST',
    contentType: 'application/json; charset=utf-8',
    data: '{}',
    dataType: 'json',
    url: 'MyPage.aspx/SomePageMethod',
    success: function(result){
        alert(result);
    }
});

请求/响应头,按在FF3萤火,现报告如下。

The request/response headers, as per Firebug in FF3, are as follows

Response Headers
Server  ASP.NET Development Server/8.0.0.0
Date    Tue, 24 Feb 2009 18:58:27 GMT
X-AspNet-Version    2.0.50727
Cache-Control   private
Content-Type    text/html; charset=utf-8
Content-Length  108558
Connection  Close

Request Headers 
Host    localhost:2624
User-Agent  Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6
Accept  application/json, text/javascript, */*
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset  ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive  300
Connection  keep-alive
Content-Type    application/json; charset=utf-8
X-Requested-With XMLHttpRequest
Referer http://localhost:2624/MyApp/MyPage.aspx
Content-Length  2
Cookie  ASP.NET_SessionId=g1idhx55b5awyi55fvorj055;

我添加了一个ScriptManager到我的网页只是踢,看它是否帮助,但没有运气。

I've added a ScriptManager to my page just for kicks to see if it helped, but no luck there.

有什么建议?

推荐答案

你知道吗,页面方法是否工作正常?如果您使用的的ScriptManager做他们的工作?

Do you know that Page Methods are working properly? If you use the the ScriptManager do they work?

这听起来像你可能会丢失一个web.config项。特别是的HttpModules部分。

It sounds like you might be missing a web.config entry. Specifically the HttpModules section.

这篇关于呼叫使用jQuery ASP.NET PageMethod的/的WebMethod - 返回整个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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