87,992
社区成员
发帖
与我相关
我的任务
分享
ar obj = { item: {item1:1,item2:2}
};
var arg = JSON.stringify(obj);
$.ajax({
type: "Post",
datatype: "json",
url: "http://pc1234567/Service/Service1.svc/hello",
data: arg,
contentType: "application/json; charset=utf-8",
beforeSend: function (xhr) {
xhr.setRequestHeader("Accept", "application/json")
},
success: function (data, textStatus, xhr) {
if (data != null) {
$("#txtmsg").val(data.msg);
}
},
error: function (xhr, textStatus, errorThrown) {
alert(xhr.responseText);
}
});
<%@ServiceHost Language="c#" Debug="true" Service="xx.xx" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
这样就能直接访问了,但是web.config里面的配置需要删掉。删掉之后,在asp.net的客户端却不能引用参照了,比较头疼。这个先结掉了