Hi,

I am trying to authenticate a user via a HTML Form using AJAX.
I'm trying to submit a HTML form to a REST API(created by pubudu)  and it
fails. I have several issues here.


   1.

   I'm making a CORS request. ( My app resides in localhost:3000/login.html &
   My server resides in http://10.100.4.135:9763/ )
   2.

   The REST API (created by pubudu) in http://10.100.4.135:9763/ accepts
   JSON requests and give back a JSON Responce.

(I have disabled the web-security in the browser to allow the CORS Requests)

So, I have created the HTML Form and tried to submit it with AJAX. Here you
can see the code.

$(function(){
    $("#loginform").submit(function(e){

        e.preventDefault();
//      var data = $("#loginform").serialize();

            var data =  {"username" : $("#username").val(),"password"
: $("#password").val()};

        alert(JSON.stringify(data));

        $.ajax({
            type: "POST",
            url: "http://localhost:3001/Login/auth";,
            data: data,

            contentType: "application/json",
            crossDomain : true,
            dataType: "json",
            success: function(data) {

                alert("success" + JSON.stringify(data));

            },
            error:function(data){
                alert('error : '+JSON.stringify(data));
            }

        });

    });});

When I submit a form, I get an error like this.

POST http://10.100.4.135:9763/dashboardConfigs/dashBoardConfigs/login 500
(Internal Server Error)

But, When I try to send the request via ADVANCED REST CLIENT. I get the
response *true*.
[Please refer the image attached]


Can anyone help me out here?

-- 
Mohammed Fawsan
Software Engineering Intern,
Faculty of Engineering, University of Peradeniya.
+94771121195
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to