1 $.ajax({ 2 url : rootPath +‘/jasframework/choosepilecontrol/querySubsytem.do‘, 3 type : "POST", 4 dataType : "json", 5 success:function(data){ 6 if(data.subsystem!=null){ 7 var length = data.subsystem.length; 8 var option = new Option(‘-----请选择-----‘,‘‘); 9 subsystemSelectObj.add(option); 10 if(length>0){ 11 for(var i=0;i<data.subsystem.length;i++){//循环数组,添加子节点 12 var eventid = data.subsystem[i].EVENTID; 13 var name = data.subsystem[i].SUBSYSTEMNAME; 14 var option = new Option(name,eventid); 15 subsystemSelectObj.add(option); 16 } 17 subsystemSelectObj.options[0].selected=true; 18 if(callback){ 19 callback();//调用页面传递进来的回调函数,主要用于修改页面设置分区值 20 } 21 } 22 } 23 } 24 }); 3.在请求前进行操作
1 $.ajax({ 2 type: "put", 3 url: szURL, 4 async: false, 5 timeout: 15000, 6 processData: false, 7 data: xmlDoc, 8 beforeSend: function(xhr) { 9 xhr.setRequestHeader("If-Modified-Since", "0"); 10 xhr.setRequestHeader("Authorization", "Basic " + g_oCommon.m_szUserPwdValue); 11 }, 12 error:function(xhr, textStatus, errorThrown) { 13 that.setState(xhr); 14 } 15 });
当含有请求失败时候的案例
1 $("#btnendsave").click(function(){ 2 $.ajax({ 3 url : rootPath +‘/jasframework/choosepilecontrol/queryMarkerById.do?MarkerId=‘+$(‘#endMarkerId1‘).val(), 4 type : ‘POST‘, 5 success : function(data) { 6 var objJson = JSON.parse(data); 7 if($(‘#endMarkerPostion1‘).val()!=‘‘){ 8 $(‘#‘+endMarkerTextId).val(objJson[0].markername+"+"+$(‘#endMarkerPostion1‘).val()+"m"); 9 }else{ 10 $(‘#‘+endMarkerTextId).val(objJson[0].markername); 11 } 12 13 }, 14 error : function(data) { 15 top.showAlert(‘错误‘, ‘查询出错‘, ‘error‘); 16 } 17 });
时间: 2024-11-06 13:22:57