Thanks...
WCF with Jquery
I want to consume a wcf service using Jquery. How can I achieve this.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Nov 27, 2013, 9:52 PM EST
http://www.c-sharpcorner.com/UploadFile/dacca2/understand-jquey-ajax-function-call-method-in-wcf-service/
http://www.codeproject.com/Articles/132809/Calling-WCF-Services-using-jQuery
http://pranayamr.blogspot.in/2010/12/steps-to-call-wcf-service-using-jquery.html
Ramchan5 reputationPosted Nov 28, 2013, 12:01 AM EST
<script>
$(document).ready(function () {
$.ajax({
type: "POST",
url: "WCFService.svc/GetEmpdetails",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
var value = JSON.stringify(response);
alert(value);
},
failure: function (response) {
alert(response.d);
}
});
});
script>
Santhosh Subramaniam189 reputationPosted Nov 28, 2013, 12:04 AM EST
Step 1 : Create WCF Application
Step 2 : Create Client Application
function getDetails(UserId) {
jQuery.support.cors = true;
$.ajax({
crossDomain: true,
type: "GET",
url: 'Your Service application URL',
contentType: "application/json; charset=utf-8",
dataType: "json",
data: '', //JSON.stringify(jData),
success: filldata,
error: function (xhr, reason, ex) {
var err = $.parseJSON(xhr.responseText);
if (err == null) {
alert('Error Code : ' + xhr.status + "\nError Message :" + xhr.statusText);
} else {
alert('Error Code : ' + xhr.status + "\nError Message :" + err.Message);
}
}
});
}
function filldata(data) {
var json = $.parseJSON(data);
Do Something here ;;;
}