本文介绍了Web服务从Web方法获取字符串数据时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!
我已经创建了一个Web服务,我想从ajax帖子发送ID并想要获取
名称作为Web服务的响应.但是我出错了.当debugg发出成功命令时
Hi!
I have created a web service, I want to send id from ajax post and want to get the
name as response from web service. But I am getting error. when debugg goes on success command
<script type="text/javascript">
function callme()
{
var postData ={'id':'4'};
var pdataJSON=JSON.stringify(postData);
$.ajax({
type: 'POST',
contentType: 'application/json',
url: '/JSON/WebService.asmx/GetName',
dataType: "json",
data:pdataJSON,
success: function(responseText){
alert(data.responseText);
},
error: function(jqXHR, textStatus, errorThrown){
alert(jqXHR, textStatus, errorThrown);
}
});
}
</script>
以下是网络服务
Following is a web service
[WebMethod]
public string GetName(Int32 id)
{
var result = from p in obj.tblPersons
where p.id == id
select p;
return result.First().name;
}
请帮助我
please help me
推荐答案
以下是网络服务
Following is a web service
[WebMethod]
public string GetName(Int32 id)
{
var result = from p in obj.tblPersons
where p.id == id
select p;
return result.First().name;
}
请帮助我
please help me
[WebMethod]
public string GetName(Object id)
{
var result = from p in obj.tblPersons
where p.id == id
select p;
return result.First().name;
}
请检查一次您的代码.
please check your code once. it may helps you.
这篇关于Web服务从Web方法获取字符串数据时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!