Click here to Skip to main content
15,171,318 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have written a wcf service and Iam calling that from javascript.But I couldnt view any response
My code is ..
<html xmlns="">
<head runat="server">
<script type="text/javascript"                   src="">

function invokeService() {
contentType:"application/json; charset=utf-8",
function AjaxSucceeded(result)
function AjaxFailed(result){
<form id="form1" runat="server">
<input type="button" onclick="javascript:invokeService();" value="Call WCF Service" />

How can I resolve it?Im getting neither errors nor response ?Where I am going wrong?
Updated 27-Aug-12 0:38am
pramod.hegde 27-Aug-12 6:38am
Calling WCF comes later.
First check, this javascript function is getting called or not.
Couple of points:
1. Syntax Fix:
Option 1. $(document).ready(function(){...} should be loaded when the form/body of the page loads. Not at the point when you click on any button. The syntax does not look proper here. Fix this first.
Option 2. Completely remove $(document).ready(function(){ line. This is no longer needed.
Option1 needs slightly more modification than Option2. So better you fix the syntax using Option2.
2. WCF Service/Binding:
To call WCF Service, check the type of the service. It should be AjaxEnabledWCF service. Also check the binding. It should be webHttpBinding.
3. Service Return type:
You are expecting the response as 'json'. Check the service response type. It should be 'JSon'.
cutie1 27-Aug-12 7:14am
$(document).ready(function(){...} .This function is not getting loaded .Can u please tell me where should I modify ?binding is webhttp and it is perfectly returning response in JSON format.So can u please suggenst me where Am I going wrong..How can I verify whether it is AjaxEnabledWCF?What are the modifications I have to do in the above code ?
cutie1 27-Aug-12 7:43am
Should I attach any jquery library in the project?

1 solution

cutie1 27-Aug-12 6:09am
In the link u gave can u please tell me where I have to write that script tag..In the web.config file?
Prabhakaran Soundarapandian 27-Aug-12 6:13am
you have to write the <system.servicemodel>.. in web.config file.The <script> tag should be in your asp page only.
cutie1 27-Aug-12 7:16am
Eventhough I couldn't view response

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

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