使用digest auth,jquery ajax调用消耗RestFul PHP webservice

时间:2012-06-27 19:04:36

标签: jquery ajax web-services rest digest-authentication

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

当我创建基本请求时,服务器需要auth,但我不知道如何发送用户名和密码。我需要这个用于phonegap app。

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

});

谢谢,

1 个答案:

答案 0 :(得分: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);
    }
});
相关问题