问题描述
在aspx頁面中有多個input按鈕,每個按鈕的邏輯不一樣需要寫多個handler.ashx文件嗎,不是很麻煩,有甚麼辦法嗎
解决方案
解决方案二:
你完全可以传一个值过去,比如type然后在同一个handler.ashx里根据接收type的值调用不同的方法返回相应的内容
解决方案三:
可以写多个ashx对应,也可以写一个带参数。后台根据参数处理。
解决方案四:
用一个调另一个function()参考:functionGetChamberIDList(EQID){if(EQID=="All"){varmodule=$("#ddModuleList").val();$('#ddChamberList').empty();$.ajax({type:"POST",contentType:"application/json",url:"/FDCService/FDCService1.asmx/GetAllEQChamberIDs",//data:"{moduleID:'"+module+"'}",datatype:'json',success:function(result){try{$(result.d).each(function(){$("#ddChamberList").append("<optionselected='selected'value='"+this+"'>"+this+"</option>");});GetRecipeIDList();}catch(e){alert(e);}},error:function(result,status){if(status=='error'){alert(result);}}});}else{$.ajax({type:"POST",contentType:"application/json",url:"/FDCService/FDCService1.asmx/GetChamberIDs",data:"{eqID:'"+EQID+"'}",datatype:'json',success:function(result){try{$('#ddChamberList').empty();$(result.d).each(function(){$("#ddChamberList").append("<optionselected='selected'value='"+this+"'>"+this+"</option>");});GetRecipeIDList();}catch(e){alert(e);}},error:function(result,status){if(status=='error'){alert(result);}}});}}functionGetRecipeIDList(){varmodule=$("#ddModuleList").val();//GetmodulevarEQID=$('#ddToolList').val();//GetEQIDvarchamberList=$("#ddChamberList").val();//GetchamberIDselecteditems$('#recipelList').empty();if(EQID=="All"){varEQIDList=$("#ddToolListoption")$(EQIDList).each(function(){varaEQID=this.value;$(chamberList).each(function(){$.ajax({type:"POST",contentType:"application/json",url:"/FDCService/FDCService1.asmx/GetRecipeIDs",data:"{eqID:'"+aEQID+"',chamberID:'"+this+"'}",datatype:'json',success:function(result){try{$(result.d).each(function(){$("#recipelList").append("<optionselected='selected'value='"+this+"'>"+this+"</option>");});}catch(e){alert(e);}},error:function(result,status){if(status=='error'){alert(result);}}});});});}else{$(chamberList).each(function(){$.ajax({type:"POST",contentType:"application/json",url:"/FDCService/FDCService1.asmx/GetRecipeIDs",data:"{eqID:'"+EQID+"',chamberID:'"+this+"'}",datatype:'json',success:function(result){try{$(result.d).each(function(){$("#recipelList").append("<optionselected='selected'value='"+this+"'>"+this+"</option>");});}catch(e){alert(e);}},error:function(result,status){if(status=='error'){alert(result);}}});});}}