0

我正在调用登录网络服务。但我无法检查我将从服务器获得什么。我懂了

**http://isuite.c-entron.de/CentronService/REST
                Username:         qus
                Password:          1** 

我检查浏览器http://isuite.c-entron.de/CentronService/REST&&Username=qus?Password= 1

但没有得到任何东西。

其次,我使用 ajax 像这样 404 会得到 .Is 这种调用 Web 服务的方式。

$(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://isuite.c-entron.de/CentronService/REST",
            dataType: 'json',
            async: false,
            //json object to sent to the authentication url
            data: '{"Username": "' + userName + '", "Password" : "' + password + '"}',
            success: function () {
                //do any process for successful authentication here
            }
        })
    }

这是小提琴 http://jsfiddle.net/LsKbJ/1/

4

1 回答 1

0

尝试在 ajax 中使用 crossDomain: true 。此外,您的数据部分是错误的。我在下面更正了它:

$.ajax
    ({
        type: "POST",
        //the url where you want to sent the userName and password to
        url: "http://isuite.c-entron.de/CentronService/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
        }
    })
于 2013-09-30T16:36:20.267 回答