jQuery Ajax实例参考

    //ajax请求数据

    var sendData = {
                    "action": "flightstop",
                    "flightno": _dataArray[0],
                    "s": _dataArray[1],
                    "e": _dataArray[2],
                    "sd": _dataArray[3],
                    "r": Math.random()
                };
               //设置30秒超时
                var timeoutvalue = 30 * 1000;
                $.ajax({
                    type: "get", //请求方式
                    dataType: "json",//请求数据类型
                    url: "SearchHandler",
                    data: sendData,//请求数据
                    timeout: timeoutvalue,//请求超时时间
                    success: function (data, status) {//请求成功处理方法
                        if (data.code == "0000") {
                            $("#" + _span_id).html("<font color='#0069ca'>经停:" + data.airport + "(" + data.arrivetime + "到达," + data.leavetime + "起飞)</font>");
                        }
                        else {
                            $("#" + _span_id).html("经停");
                        }
                    },
                    error: function () {//请求失败处理方法
                    }
                });

posted @ 2015-05-03 23:10  HunterDong  阅读(462)  评论(0编辑  收藏  举报