如何通过使用jQuery的ajax调用webservice的凭据? [英] how to pass credentials for a webservice using jquery ajax call?

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

问题描述

我使用这样的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");
                },
    });

还是呼叫不会Web服务。每次我收到错误警报。可一些身体帮我在这吗?

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

推荐答案

尝试使用后的方法类型,大多数Web服务被固定并使用后需要transimssion,并没有得到

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调用webservice的凭据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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