jQuery的阿贾克斯楼盘Asp.Net 2.0 [英] Jquery's Ajax Property For Asp.Net 2.0
本文介绍了jQuery的阿贾克斯楼盘Asp.Net 2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我总是看到code像这样的博客:
$。阿贾克斯({
键入:POST,
的contentType:应用/ JSON的;字符集= UTF-8,
网址:WebService.asmx / HelloWorld的,
数据: {},
数据类型:JSON,
成功:函数(MSG){
警报(msg.d);
}
});
但我认为这仅仅是与asp.net 3.5中运行。我无法与2.0运行它。我怎么可以用这样这些C $ CS $在我的应用程序?
解决方案
您需要将此属性添加到您的网络服务器类
[System.Web.Script.Services.ScriptService]
公共类服务:System.Web.Services.WebService
和这个属性给函数的
[ScriptMethod(ResponseFormat = ResponseFormat.Json)
您在技术上不指定responseformat,因为它根据响应 该格式您在请求中指定。而你的必须的指定要求的格式。
问候
氏/ P>
I always see the code like this in the blogs:
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "WebService.asmx/HelloWorld",
data: "{}",
dataType: "json",
success: function(msg) {
alert(msg.d);
}
});
But I think this is run only with asp.net 3.5. I couldn't run it with 2.0. How can I use such these codes in my Applications?
解决方案
You need to add this attribute to your webserver class
[System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
and this attribute to your functions
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
You don't technically need to specify the responseformat, as it responds according to the format you specify in the request. And you must specify a format in the request.
Regards
K
这篇关于jQuery的阿贾克斯楼盘Asp.Net 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文