1

我想知道如何使用摘要身份验证调用 RestFul PHP webservice ?

当我创建我的基本请求时,服务器需要身份验证,但我不知道如何发送用户名和密码。我需要这个用于phonegap应用程序。

$.ajax({
    type: "GET",
    url: "http://webservice",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (msg) {
        alert(msg);
    }

});

谢谢,

4

1 回答 1

0

data调用时使用参数$.ajax

$.ajax({
    type: "GET",
    url: "http://webservice",
    data: {username:'Your Username', password:'Your Password'},
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (msg) {
        alert(msg);
    }
});
于 2012-06-27T21:33:58.127 回答