使用 JQuery ajax post 使用 WCF/REST 服务

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5348128/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 19:00:49  来源:igfitidea点击:

Consuming WCF / REST service using JQuery ajax post

jqueryajaxwcfinternal

提问by user601367

I am trying to post the data usign $.ajax, but I am getting failure message 400 error. Following is the code:

我正在尝试使用 $.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);
                }

            });

采纳答案by Pranay Rana

here is my blog post for you : Create REST service with WCF and Consume using jQuery

这是我的博客文章:使用 WCF 创建 REST 服务并使用 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

带有 WCF 的 REST 服务和使用 jQuery 通过 post 进行消费,您可以轻松地找出问题,但只需步行 2 或 3 分钟

Others

其他

Steps to Call WCF Service using jQuery

使用 jQuery 调用 WCF 服务的步骤

Calling Cross Domain WCF service using Jquery/Javascript

使用 Jquery/Javascript 调用跨域 WCF 服务