如何使用Ajax调用Web服务 [英] how to call a web services using ajax

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

问题描述

我正在尝试使用Ajax调用我的Web服务.我已经在虚拟机中部署了Web服务.

URL:

http://www.lumiin.ch:8080/lumiin-service/lumiin/control/vprospects

使用Rest client Jar尝试使用此URL

方法= GET
键=接受
值= Application/json

**下面的我的代码**



$ .ajax({
类型:"GET",//GET或POST或PUT或DELETE动词
url:"http://www.lumiin.ch:8080/lumiin-service/lumiin/control/vprospects",//服务位置
data:",//发送到服务器的数据
contentType:"application/json",//发送到服务器的内容类型
dataType:"json",//来自服务器的预期数据格式
processdata:true,//True或False
成功:函数(数据){//在成功的服务调用中

var result = json.name;
alert("result ===" +结果);
$(#dvAjax").html(result);
},
错误:ServiceFailed//当服务调用失败时
});


返回false;
});

});

但是我没有从上面的代码中得到任何回应.请帮助我.

Regd的Karthick

I am trying to use ajax to call my web services. Already i have deployed my web-service in my virtual machine.

URL:

http://www.lumiin.ch:8080/lumiin-service/lumiin/control/vprospects

Try this URL with Rest client Jar

Method = GET
Key = accept
value = Application/json

**My Code below**



$.ajax({
type: "GET", //GET or POST or PUT or DELETE verb
url: "http://www.lumiin.ch:8080/lumiin-service/lumiin/control/vprospects", // Location of the service
data: "", //Data sent to server
contentType: "application/json", // content type sent to server
dataType: "json", //Expected data format from server
processdata: true, //True or False
success: function (data) {//On Successfull service call

var result = json.name;
alert("result===" + result);
$("#dvAjax").html(result);
},
error: ServiceFailed// When Service call fails
});


return false;
});

});

But I am getting no response from the above code. Please help me out in this.

Regd''s Karthick

推荐答案

.ajax({
类型:"GET",//GET或POST或PUT或DELETE动词
url:"http://www.lumiin.ch:8080/lumiin-service/lumiin/control/vprospects",//服务位置
data:",//发送到服务器的数据
contentType:"application/json",//发送到服务器的内容类型
dataType:"json",//来自服务器的预期数据格式
processdata:true,//True或False
成功:函数(数据){//在成功的服务调用中

var result = json.name;
alert("result ===" +结果);
.ajax({
type: "GET", //GET or POST or PUT or DELETE verb
url: "http://www.lumiin.ch:8080/lumiin-service/lumiin/control/vprospects", // Location of the service
data: "", //Data sent to server
contentType: "application/json", // content type sent to server
dataType: "json", //Expected data format from server
processdata: true, //True or False
success: function (data) {//On Successfull service call

var result = json.name;
alert("result===" + result);


(#dvAjax").html(result);
},
错误:ServiceFailed//当服务调用失败时
});


返回false;
});

});

但是我没有从上面的代码中得到任何回应.请帮助我.

Regd的Karthick
("#dvAjax").html(result);
},
error: ServiceFailed// When Service call fails
});


return false;
});

});

But I am getting no response from the above code. Please help me out in this.

Regd''s Karthick


首先在测试页上进行操作

步骤1:将ur服务的网络参考添加到ur项目中

步骤:2在javascript页面中

do it on a test page first

step1: add web reference of ur service to ur project

step:2 in javascript page


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

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