Error code 12031 in Ajax enabled wcf

Error code 12031 in Ajax enabled wcf

29 Mar 2024
2 min read

From last couple of days I was trying to call a ajax enabled wcf service method with the help of jquery. But each and every time I am getting the error code 12031 returned by the service. I did googling for this error but I was unable to find the solution. After spending much time on R&D, I found the reason why I wa geeting this error.

In this article, I am going to share my experience with you so that you will be able to resolve this error in ajax enabled wcf service. I have the below service and code for calling wcf.

WCF Service

 WCF Service Method Calling Code
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script> <script type="text/javascript">
 $('#btn').live('click', function () {
 // debugger;
 var value = $('#txtEmpID').val();
 if (value != '') {
 var strJSONFilterCriteria = '{"mEmpID":"' + value + '"}';
 $.ajax({ type: "POST", contentType: "application/json; charset=utf-8",
 url: '<%=ViewState["WCFBalUrl"]%>' + '/GetEmpInfo',
 data: strJSONFilterCriteria,
 dataType: "json",
 error: function (msg) {
 // debugger;
 alert('Service call failed: ' + msg.status + ' Type :' + msg.statusText);
 success: function (msg) {
 var str = "Emp ID:" + msg.d.EmpID + "\n";
 str += "Emp Name:" + msg.d.Name + "\n";
 str += "Emp Salary:" + msg.d.Salary + "\n";
 //str += "JoiningDate:" + new Date(parseInt(msg.d.JoiningDate.substr(6))) + "\n";
 } }); }
 return false;
 WCF Error Code 12031
 To learn more about Dot Net Tricks visit <a href="" title="Dot Net Tricks "></a>.
 Enter Employee ID (1-3)
 <asp:TextBox ID="txtEmpID" runat="server" ClientIDMode="Static"></asp:TextBox>
  <asp:Button ID="btn" runat="server" Text="Get Info" ClientIDMode="Static" />

I hope you will enjoy this trick while programming with Ajax enabled WCF. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.

Share Article
Batches Schedule
About Author
Shailendra Chauhan (Microsoft MVP, Founder & CEO at Scholarhat by DotNetTricks)

Shailendra Chauhan is the Founder and CEO at ScholarHat by DotNetTricks which is a brand when it comes to e-Learning. He provides training and consultation over an array of technologies like Cloud, .NET, Angular, React, Node, Microservices, Containers and Mobile Apps development. He has been awarded Microsoft MVP 8th time in a row (2016-2023). He has changed many lives with his writings and unique training programs. He has a number of most sought-after books to his name which has helped job aspirants in cracking tough interviews with ease.
Self-paced Membership
  • 22+ Courses
  • 750+ Hands-On Labs
  • 300+ Quick Notes
  • 55+ Skill Tests
  • 45+ Interview Q&A
  • 10+ Real-world Projects
  • Career Coaching
  • Email Support
Upto 66% OFF

To get full access to all courses

Accept cookies & close this