I am trying to post the data usign $.ajax, but I am getting failure message 400 error. Following is the code:
$.ajax({
url: "http://192.168.1.9:150/Service.svc/usrregistration",
type: "POST",
// data: '{"Firstname":' + Firstname + ',"LastName:"'+LastName+'}',
data: '{"Firstname":"rose"}',
contentType: "application/json; charset=utf-8",
dataType: "json",
processdata: true,
success: function (msg) {
alert(msg);
alert('Registerd successfully');
},
error: function (msg) {
alert('Faild'+msg.status);
}
});
here is my blog post for you : Create REST service with WCF and Consume using jQuery
REST service with WCF and Consume using jQuery by post you can figure out the problem easily its just 2 or 3 min walk though
Others
来源:https://stackoverflow.com/questions/5348128/consuming-wcf-rest-service-using-jquery-ajax-post