ajax访问webservice接口

来源:互联网 发布:产品设计的软件 编辑:程序博客网 时间:2024/06/05 06:21

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);                            }                        });