locked
Calling WCF service from jQuery Ajax using POST method RRS feed

  • Question

  • User-237409212 posted

    var     AddUser = "http://12.168.176.125/WcfRestService/Service1.svc/UserPost";

    function

    adduser() {

               

    var UserInfo = [{

                   

    "UserId": 2,

                   

    "uAlias": "v-lujin",

                   

    "uPassword": "123",

                   

    "uFirst_Name": "lu",

                   

    "uLast_Name": "jing",

                   

    "uState": "yes"

               

    }];

                $

    .ajax({

                    type

    : "POST",

                    url

    : AddUser,

                    data

    : JSON.stringify(UserInfo),

                    dataType

    : "json",

                    processData

    : false,

                    contentType

    : "application/json;charset=utf-8",

                    success

    : function () {

                        alert

    ("success");

                   

    },

                    error

    : function (error) {

                        alert

    (JSON.stringify(UserInfo));

                   

    }

               

    });

           

    }

    Friday, January 30, 2015 2:03 AM

Answers

  • User-237409212 posted

    Thank you for your help.

    I have solved this question. The reason is the data type which I want to post did not match the data type of database.

    Best wish

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 4, 2015 4:32 AM

All replies

  • User-484054684 posted

    You are using $ ajax with POST option in your code and you are passing JSON object to it and yes that looks to be fine. Just also ensure to consume the result object (if any) in the success event handler. Let us know if you are facing any issue or problem.

    Friday, January 30, 2015 2:57 PM
  • User-237409212 posted

    Thank you for your help.

    I have solved this question. The reason is the data type which I want to post did not match the data type of database.

    Best wish

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 4, 2015 4:32 AM