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