ajax访问webservice接口

本文介绍了如何利用Ajax技术来访问WebService接口。首先讲解了使用mui框架进行Ajax请求的步骤,接着详细阐述了标准的Ajax请求方法。通过这两种方式,开发者可以实现前后端数据的异步交互。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.使用mui框架的ajax请求

mui.ajax('http://192.168.100.93:8080/oaWebService/standardService/app/getAuditMsg', {
                     //webservice接口中方法需要的参数
                            data: {
                                arg0: 'mpp',
                                arg1: 'e6e061838856bf47e1de730719fb2609'
                            },
                            type: 'get', //HTTP请求类型  
                         //强制跨域     
                          dataType: 'jsonp', //服务器返回json格式数据  
                            jsonp: "json",
                            crossDomain: true,
                            timeout: 10000, //超时时间设置为10秒; 
                            //headers: { 'Content-Type': 'application/json' },
                            success: function(data) {

                            },
                            error: function(xhr, type, errorThrown) {
                                //异常处理; 
                                console.log(xhr);
                                console.log(type);
                                console.log(errorThrown);
                                mui.alert(type);
                            }
                        });

2.正常标准的ajax

$.ajax({
                            type: "post",
                            url: "http://192.168.100.93:8080/oaWebService/standardService/app/getAuditMsg",
                            dataType: "jsonp",
                            jsonp: "json",
                            data: {
                                arg0: 'mpp',
                                arg1: 'e6e061838856bf47e1de730719fb2609'
                            },
                            success: function(result) {
                                console.log("data from service :" + result);
                            },
                            error: function(a, b, c) {
                                alert(c);
                            }
                        });
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值