如何使用 jquery ajax 调用传递 Web 服务的凭据? [英] how to pass credentials for a webservice using jquery ajax call?

查看:32
本文介绍了如何使用 jquery ajax 调用传递 Web 服务的凭据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这样的 jquery ajax 调用:

I am using the jquery ajax call like this:

$.ajax({
         url: WEBSERVICE_URL,
            type: "GET",
            dataType: "application/json; charset=utf-8",                   
            username: "admin",  // Most SAP web services require credentials
            password: "admin",
            processData: false,
            contentType: "application/json",
            success: function() {
               alert("success");
            },
            error: function() {
                   alert("ERROR");
                },
    });

呼叫仍然不会转到网络服务.每次我收到错误警报.请问有人可以帮助我吗?

still the call is not going to web service. Everytime I am getting ERROR alert. Can some body help me on this please?

推荐答案

尝试使用 post 作为方法类型,大多数 webservices 是安全的并且需要使用 post 而不是 Get 进行传输

Try using post for the method type, most webservices are secured and require transimssion using post and not Get

加上帮助您调试错误和对错误的响应文本.

plus to help you debug the error and a response text to your error.

 $.ajax({
     url: WEBSERVICE_URL,
     type: "POST", //This is what you should chage
     dataType: "application/json; charset=utf-8",
     username: "admin", // Most SAP web services require credentials
     password: "admin",
     processData: false,
     contentType: "application/json",
     success: function () {
         alert("success");
     },
     error: function (xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
         alert(xhr.status);
         alert(xhr.responseText);
     },
 });

这篇关于如何使用 jquery ajax 调用传递 Web 服务的凭据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆