Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have build WCF Rest service and i am trying to call it from javascript.The method gets called properly when invoked directly from browser however nothing happens when i call it using javascript.
C#
[WebGet(
       ResponseFormat = WebMessageFormat.Json,
       BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "convertcadtoimg")]
       [OperationContract]
       string convertcadtoimg();


JavaScript
jQuery.support.cors = true;
       $.ajax({
           type: "GET",
           url: "http://localhost:2881/RestServiceImpl.svc/convertcadtoimg",
           //data: { domain: domainName, website: sitename },
           dataType: "jsonp",
           contentType: "application/json; charset=utf-8",
           success: function (data) {
               alert('success');

           },
           error: function (jqXHR, textStatus, errorThrown) {
               alert('error');

           }
       });
Posted
Comments
Kornfeld Eliyahu Peter 13-Aug-14 6:09am    
Can you explain 'nothing happens'?
The server side got hit? There are messages in the browsers' console?
Dexter11 13-Aug-14 6:40am    
No, the request did't reach server side. It didn't even show any errors on console.
Kornfeld Eliyahu Peter 13-Aug-14 6:57am    
Try this: http://www.codeproject.com/Articles/128478/Consuming-WCF-REST-Services-Using-jQuery-AJAX-Call
Look closely for uri template...

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