Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have a RestFul service, which provides several interfaces for different functionalities. I want to send a request envelop (e.g. uid and password for Authentication) and process the response.

I am trying using jQuery, Ajax but when I sent a https request then it gives me the following respose.
{"readyState":0,"responseText":"","status":0,"statusText":"error"}

Here is my code sample.

C#
url: "https://mysite/login",
        type: "POST",
        data: {  // the parameters of the request. This should be adapted to your case
            "uid": uname,
            "password": pswd
        },
        dataType: 'json',
        contentType: 'application/json',
        headers: { 'My-Key': 'ABCMDJDFJFDFKDFEKEKRKR39; },
/*       beforeSend: function(xhr) {
            xhr.setRequestHeader('My-Key', 'ABCMDJDFJFDFKDFEKEKRKR3');
          },*/
        async: true,
        crossDomain: true,

        success:function () {
//      data: JSON.stringify(data);
        var obj=jQuery.parseJSON(data);
       // alert("success");
        console.log(data);
        alert(JSON.stringify(data)+" Success");
    //JSON.parse(t);

        },
        error:function(data){
//      data: JSON.stringify(data);
        //var obj1=jQuery.parseJSON(JSON.stringify(data));
        //var x= JSON.parse("two"+data);
        console.log(data);
        //alert(resp.responseText);
        alert(JSON.stringify(data)+" error");
        }



I tried using "beforeSend" function but the result is same.

I found out that I need to send certificate or key-store details to the server then it will give me proper response. Please let me know what are the ways that I can send these details. I know it is not possible using jQuery, Ajax. So what are the other alternatives that I can go for?



Regds
Posted
Updated 16-Dec-13 19:16pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900