Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript REST
Hii
 
How can I call a REST service using Javascript? My REST response is in JSON format...]
 
Thanks,,,
Posted 27-Aug-12 1:35am
cutie1297

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Manas Bhardwaj at 27-Aug-12 8:36am
   
Good +5
Prasad_Kulkarni at 28-Aug-12 0:04am
   
Thank you Manas!
cutie1 at 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)



Advertise | Privacy | Mobile
Web04 | 2.8.141015.1 | Last Updated 29 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100