Linked Questions

Popular Questions

AJAX call to rest service to post the data from HTML form

Asked by At

    <form method="POST">
            <input id="username" name="username" type="text">
                <input id="emailid" name="emailid" type="text">
                <button id="enter" type="submit">submit</button>
    <script type="text/javascript">
        $(document).ready(function () {
            var userName = $("#username").val();
            var emailId = $("#emailid").val();
            $($enter).click(function () {
                    type: 'POST',
                    url: " service url....",
                    dataType: JSON,
                    data: {
                        "UserName": userName,
                        "EmailId": emailId
                    success: function (data) {
                    error: function (e) {
                        alert("error" + e)


I'm trying to post the form field in rest service which expects a JSON response. I'm getting an alert error message (object Object)

I'm not getting where the error is.

Related Questions