0

I am calling login web service.But I am not able to check what I will get from server . I do like this ? Here is my url and parameter

Here is my try http://jsfiddle.net/LsKbJ/2/

$(document).ready(function () {
        //event handler for submit button
        $("#btnSubmit").click(function () {
            //collect userName and password entered by users
            var userName = $("#username").val();
            var password = $("#password").val();

            //call the authenticate function
            authenticate(userName, password);
        });
    });

    //authenticate function to make ajax call
    function authenticate(userName, password) {
       $.ajax
    ({
        type: "POST",
        //the url where you want to sent the userName and password to
        url: "http://ii.c-cc.de/pp/REST",
        dataType: 'json',
        async: false,
        crossDomain: true,
        //json object to sent to the authentication url
        data: {Username: userName, Password: password},
        success: function () {
            //do any process for successful authentication here
        }
    })
    }
user2648752
  • 2,123
  • 5
  • 21
  • 29
  • Your endpoint returns 404 for POST requests. – haim770 Oct 01 '13 at 06:36
  • try using ,error:function(data){alert(data)} – Anuj Aneja Oct 01 '13 at 06:37
  • yes ...It mean server is not found .But server is running.. – user2648752 Oct 01 '13 at 06:37
  • Is the URL you using is correct? (I mean "CentronService/REST" part) – Anuj Aneja Oct 01 '13 at 06:39
  • yes my friend given this url – user2648752 Oct 01 '13 at 06:43
  • you can check also this http://isuite.c-entron.de/CentronService/REST/help/operations/Login – user2648752 Oct 01 '13 at 06:44
  • Show your `Web.Config`. you're probably having a problem with the host binding. your current http://isuite.c-entron.de/CentronService is currently shown to be bound to `localhost`. also, your url for `Login` should be http://isuite.c-entron.de/CentronService/REST/Login. – haim770 Oct 01 '13 at 06:49
  • It mean I don't understand .. – user2648752 Oct 01 '13 at 06:50
  • If I check this ..http://jsfiddle.net/ravi1989/LsKbJ/6/ – user2648752 Oct 01 '13 at 06:56
  • It show bad request ..!! – user2648752 Oct 01 '13 at 06:56
  • It shows bad requests because you're running into `cross-domain-request` issue (ajaxing from 'jsfiddle.net' to 'isuite.c-entron.de') and the browser tries to initiate a pre-flight request (which is in OPTIONS verb) that WCF won't allow unless you configure it accordingly. check http://stackoverflow.com/questions/10096449/cross-domain-jquery-ajax-request-wcf-rest-service first. – haim770 Oct 01 '13 at 07:00
  • You also need to add `contentType: "application/json; charset=utf-8",` to your ajax and make sure `data` in indeed compatible with the structure at http://isuite.c-entron.de/CentronService/REST/help/operations/Login – haim770 Oct 01 '13 at 07:03
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/38391/discussion-between-user2648752-and-haim770) – user2648752 Oct 01 '13 at 07:04

2 Answers2

0

I suggest you to create REST api to get & post data using WCF

DK Chauhan
  • 194
  • 1
  • 11
0

I think you missed the method name MyMethodName in the service URL. Also make sure there is no cross origin error in the console. You can get the list of your methods from the help page of your service url.

//authenticate function to make ajax call

url: "http://isuite.c-entron.de/CentronService/REST/MyMethodName",

Example : url: http://isuite.c-entron.de/CentronService/REST/GetLoggedInUser

Replace MyMethodName with apropriate method name in the above url of authenticate method.

sudhansu63
  • 6,025
  • 4
  • 39
  • 52
  • isuite.c-entron.de/CentronService/REST/help/operations/Login – user2648752 Oct 01 '13 at 09:13
  • In order to fix the Cross domain ajax request you need to add AccessControlAlowOrigin in the response header. http://cypressnorth.com/programming/cross-domain-ajax-request-with-json-response-for-iefirefoxchrome-safari-jquery/ – sudhansu63 Oct 01 '13 at 09:27