2013-10-02 78 views
-1

我在这个URL上调用web服务。如何使用ajax + jquery调用基于web服务的休息

这是我的代码。

http://jsfiddle.net/LsKbJ/8/

$(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({ 
     //the url where you want to sent the userName and password to 
     url: "", 
     type: "POST", 
     // dataType: 'jsonp', 
     async: false, 
     crossDomain: true, 
     contentType: 'application/json', 
     //json object to sent to the authentication url 
     data: JSON.stringify({ 
      Ticket: 'Some ticket', 
      Data: { 

       Password: "1", 
       Username:"aa" 
      } 
     }), 
     success: function (t) { 
      alert(t+"df") 
     }, 
     error:function(data){ 
      alert(data+"dfdfd") 
     } 
    }) 
} 

响应 **

**

它的意思是,我第一次调用此方法然后调用登录方法?

+0

(-1)downvoting很好的答案。 – Nancy

回答

-1

您的JavaScript需要根据后端sode团队更新为使用新的url http://isuite.c-entron.de/CentronServiceAppleDemoIndia/GetNewAuthentifikationTicket

另外,即使您这样做,由于服务需要web.config中的跨域配置条目,您将无法正确获得答复。您必须使用此参考号:http://encosia.com/using-cors-to-access-asp-net-services-across-domains/并以某种方式配置服务器的web.config,以便您可以从跨域调用它。

0

也许该消息意味着,在开发过程中,当你正在编写和测试代码,使用的网址:

http://isuite.c-entron.de/CentronServiceAppleDemoIndia/REST/GetNewAuthentifikationTicket

而不是:

http://isuite.c-entron.de/CentronService/REST/Login

因为你不” t需要开发方法的应用程序ID。你可以从错误信息看,你缺少application (gu)id

The guid '61136208-742B-44E4-B00D-C32ED26775A3' is no valid application guid

+0

你能告诉我什么是在这个函数中使用的参数GetNewAuthentifikationTicket – Rohit

+0

寻找部分标题:“以下是一个示例请求Json body:”并按照示例进行操作。也许“应用程序”参数被忽略,也许它应该有一个“空”值。您可能需要联系某人以获取更多文档和示例。 – ricksuggs

+0

请检查我的更新 – Rohit

相关问题