Consuming WCF / REST service using JQuery ajax post

24,184

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

Steps to Call WCF Service using jQuery

Calling Cross Domain WCF service using Jquery/Javascript

Share:
24,184
user601367
Author by

user601367

Updated on July 13, 2022

Comments

  • user601367
    user601367 almost 2 years

    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);
                    }
    
                });