如何使用 Ajax + jQuery 调用基于 Web 服务 REST
how to call web service rest based using 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")
}
})
}
响应**
**
这意味着我先调用此方法,然后调用登录方法?
该消息可能意味着在开发过程中,在编写和测试代码时,请使用 URL:
http://isuite.c-entron.de/CentronServiceAppleDemoIndia/REST/GetNewAuthentifikationTicket
而不是:
http://isuite.c-entron.de/CentronService/REST/Login
因为开发方法不需要应用程序 ID。您可以从错误消息中看到您缺少application (gu)id
The guid '61136208-742B-44E4-B00D-C32ED26775A3' is no valid application guid
你的javascript需要更新,以便根据后端sode团队使用新的url http://isuite.c-entron.de/CentronServiceAppleDemoIndia/GetNewAuthentifikationTicket
。
此外,即使您这样做,也无法正确获得回复,因为服务需要 web.config 中的跨域配置条目。您必须使用此引用:http://encosia.com/using-cors-to-access-asp-net-services-across-domain/并以某种方式配置服务器的 web.config,以便您可以从跨域调用它。
相关文章:
- 基于api密钥的NodeJS web服务
- 使用javascript在客户端上使用Web服务
- 如何通过安全的https连接在javascript中使用基于soap xml的Web服务
- 从Javascript连接到SOAP Web服务
- 如何将javascript对象作为参数传递到c#web服务中
- AngularJS:使用维基百科API的web服务
- 从javascript调用C#Web服务并使用它(json格式)
- 从简单的html页面调用实时Web服务.
- 在JavaScriptAjax调用中从web服务中的XMLDocument获取响应.
- 如何使用 javascript 从 Web 服务重新加载项目集合
- 创建web服务“;活动指示器”-与所有浏览器兼容的类似指示符
- 如何将WinJS ListView绑定到web服务
- Ajax不调用Web服务
- 将web服务回调的结果绑定到Javascript中的调用函数
- 如何创建可从多个应用程序使用的PHP登录web服务
- Ajax发布到双节点NLB上的web服务
- 无法使用javascript客户端访问远程web服务
- 使用带有AngularJS的DocRaptor web服务
- 如何使用phonegap在android中调用asp.net Web服务
- 如何使应用程序加载独立于web服务调用