我尝试使用 $.ajax 发布数据,但收到失败消息 400 错误。以下是代码:
$.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);
}
});
最佳答案
这是我为您准备的博客文章:Create REST service with WCF and Consume using jQuery
使用 WCF 的 REST 服务并使用 jQuery 通过 post 进行消费,您可以轻松地找出问题,只需 2 或 3 分钟的步行时间
其他
关于jquery - 使用 JQuery ajax post 使用 WCF/REST 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5348128/