Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hii

How can I call a REST service using Javascript? My REST response is in JSON format...]

Thanks,,,
Posted

1 solution

 
Share this answer
 
Comments
Manas Bhardwaj 27-Aug-12 8:36am    
Good +5
Prasad_Kulkarni 28-Aug-12 0:04am    
Thank you Manas!
cutie1 29-Aug-12 12:29pm    
I have used this code .But couldn't view any response ...
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">

function invokeService() {
$(document).ready(function(){
$.ajax({
type:"GET",
async:false,
url:"http://localhost:8732/IServices/RoleService/json/Role/doctor",
contentType:"application/json; charset=utf-8",
dataType:"json",
processData:true,
success:function(result){
AjaxSucceeded(result);
},
eror:AjaxFailed
});
function AjaxSucceeded(result)
{
alert(result);
}
function AjaxFailed(result){
alert(result.status+''+result.statusText);
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" önclick="javascript:invokeService();" value="Call WCF Service" />
</div>
</form>
</body>
How can I manage to get the response.Where Am I going wrong?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900