使用JQuery ajax帖子使用WCF / REST服务

时间:2011-03-18 04:35:04

标签: jquery ajax wcf internal

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

            });

1 个答案:

答案 0 :(得分:3)

这是我的博文:Create REST service with WCF and Consume using jQuery

使用WCF的REST服务和使用jQuery的消费通过发布你可以轻松地找出问题它只需2或3分钟的步行

<强>其他

Steps to Call WCF Service using jQuery

Calling Cross Domain WCF service using Jquery/Javascript