ajax寮傛璇锋眰
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ajax寮傛璇锋眰相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/html' title='html'>html
UNC ict for return href app instance rect闇€姹傦細闇€瑕侀€氳繃浜岀骇鑱斿姩鐨勬柟寮忓皢浜岀骇鍒楄〃鏁版嵁灞曠ず鍑烘潵
涓€绾у垪琛ㄩ€夋嫨(娉ㄦ剰瑕佺粰id璧嬪€肩敤浜庡畾浣?
<div class="control-group"> <label class="control-label">璇勫垎:</label> <div class="controls"> <form:select id="type" path="score" htmlEscape="false" style="width:270px;" class="required"> <form:option value="">----select----</form:option> <form:options items="${scoreList}" itemLabel="label" itemValue="id" /> </form:select> <span class="help-inline"><font color="red">*</font> </span> </div> </div>
銆€銆€
浜岀骇杈撳叆妗嗚仈鍔ㄥ睍绀?娉ㄦ剰瑕佺粰id璧嬪€?
<div class="control-group"> <label class="control-label">璇勫垎鍑嗗垯:</label> <div class="controls"> <form:input id="subType" path="scoreCriteria" htmlEscape="false" style="width:260px;" maxlength="125" class="required"/> <span class="help-inline"><font color="red">*</font> </span> </div> </div>
JavaScript鏂规硶锛堜竴绾у垪琛ㄥ彉鍖栧皢浼氳皟鐢ㄨ鏂规硶锛?/h3>
<script type="text/javascript">
$("#type").on("change",function(){
$.ajax({
url:"${ctx}/oc/devopsscore/selectSec",//鏍规嵁浼犵殑id鍊艰姹傚瓙绫诲瀷鐨勫湴鍧€銆?
data:"id="+this.value,
type:"post",
dataType:"json",
success:function(result){
$("#subType").val(result["description"]);
}
})
});
</script>
銆€銆€
JavaScript鏂规硶锛堜竴绾у垪琛ㄥ彉鍖栧皢浼氳皟鐢ㄨ鏂规硶锛?杩欑鏂规硶鏄皢浼犲叆鐨勬暟鎹浆鎹㈡垚閫夋嫨妗嗙殑褰㈠紡鐨勬樉绀烘柟寮?/h3>
$("#type").on("change",function(){
$.ajax({
url:"${ctx}/delivery/platform/selectSub",//鏍规嵁浼犵殑type鍊艰姹傚瓙绫诲瀷鐨勫湴鍧€銆?
data:"type="+this.value,
type:"post",
dataType:"json",
success:function(result){
$("#subType").html("");
var option1 = $("<option></option>").val("").text("--select--");
$("#subType").append(option1);
for(var i=0;i<result.length;i++) {
var option = $("<option></option>").val(result[i]).text(result[i]);
$("#subType").append(option);
}
}
})
});
銆€銆€
JavaScript鏂规硶锛堜竴绾у垪琛ㄥ彉鍖栧皢浼氳皟鐢ㄨ鏂规硶锛?杩欑鏂规硶鏄皢浼犲叆鐨勬暟鎹洿鎺ュ湪杈撳叆妗嗕腑鏄剧ず鍑?/h3>
<script type="text/javascript">
$("#type").on("change",function(){
$.ajax({
url:"${ctx}/oc/devopsscore/selectSec",//鏍规嵁浼犵殑type鍊艰姹傚瓙绫诲瀷鐨勫湴鍧€銆?
data:"value="+this.value,
type:"post",
dataType:"json",
success:function(result){
$("#subType").val(result["description"]);
}
})
});
</script>
銆€銆€
鍚庡彴鏂规硶锛?a class="user-mention" href="https://github.com/responsebody" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=31021593" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self">@responsebody涓嶈兘蹇樿鍔犱笂锛屼笉鐒禷jax鏃犳硶鎵цsuccess:function(result)锛?/h3>
@RequestMapping(value = "selectSec")
@ResponseBody
public String selectSec(OcDict ocDict, RedirectAttributes redirectAttributes) {
System.err.println("ocDict"+JsonMapper.toJsonString(ocDict));
ocDict=ocDictService.get(ocDict);
return JsonMapper.toJsonString(ocDict);
}
銆€銆€
灏唈son杞崲鎴恖ist
JavaType javaType = JsonMapper.getInstance().createCollectionType(ArrayList.class, DpmProblemReviewInfo.class);
List<DpmProblemReviewInfo> objectListData = JsonMapper.getInstance().fromJson(changeData,javaType);
銆€銆€
<script type="text/javascript"> $("#type").on("change",function(){ $.ajax({ url:"${ctx}/oc/devopsscore/selectSec",//鏍规嵁浼犵殑id鍊艰姹傚瓙绫诲瀷鐨勫湴鍧€銆? data:"id="+this.value, type:"post", dataType:"json", success:function(result){ $("#subType").val(result["description"]); } }) }); </script>
銆€銆€
$("#type").on("change",function(){ $.ajax({ url:"${ctx}/delivery/platform/selectSub",//鏍规嵁浼犵殑type鍊艰姹傚瓙绫诲瀷鐨勫湴鍧€銆? data:"type="+this.value, type:"post", dataType:"json", success:function(result){ $("#subType").html(""); var option1 = $("<option></option>").val("").text("--select--"); $("#subType").append(option1); for(var i=0;i<result.length;i++) { var option = $("<option></option>").val(result[i]).text(result[i]); $("#subType").append(option); } } }) });
銆€銆€
JavaScript鏂规硶锛堜竴绾у垪琛ㄥ彉鍖栧皢浼氳皟鐢ㄨ鏂规硶锛?杩欑鏂规硶鏄皢浼犲叆鐨勬暟鎹洿鎺ュ湪杈撳叆妗嗕腑鏄剧ず鍑?/h3>
<script type="text/javascript">
$("#type").on("change",function(){
$.ajax({
url:"${ctx}/oc/devopsscore/selectSec",//鏍规嵁浼犵殑type鍊艰姹傚瓙绫诲瀷鐨勫湴鍧€銆?
data:"value="+this.value,
type:"post",
dataType:"json",
success:function(result){
$("#subType").val(result["description"]);
}
})
});
</script>
銆€銆€
鍚庡彴鏂规硶锛?a class="user-mention" href="https://github.com/responsebody" data-hovercard-type="user" data-hovercard-url="/hovercards?user_id=31021593" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self">@responsebody涓嶈兘蹇樿鍔犱笂锛屼笉鐒禷jax鏃犳硶鎵цsuccess:function(result)锛?/h3>
@RequestMapping(value = "selectSec")
@ResponseBody
public String selectSec(OcDict ocDict, RedirectAttributes redirectAttributes) {
System.err.println("ocDict"+JsonMapper.toJsonString(ocDict));
ocDict=ocDictService.get(ocDict);
return JsonMapper.toJsonString(ocDict);
}
銆€銆€
灏唈son杞崲鎴恖ist
JavaType javaType = JsonMapper.getInstance().createCollectionType(ArrayList.class, DpmProblemReviewInfo.class);
List<DpmProblemReviewInfo> objectListData = JsonMapper.getInstance().fromJson(changeData,javaType);
銆€銆€
<script type="text/javascript"> $("#type").on("change",function(){ $.ajax({ url:"${ctx}/oc/devopsscore/selectSec",//鏍规嵁浼犵殑type鍊艰姹傚瓙绫诲瀷鐨勫湴鍧€銆? data:"value="+this.value, type:"post", dataType:"json", success:function(result){ $("#subType").val(result["description"]); } }) }); </script>
銆€銆€
@RequestMapping(value = "selectSec") @ResponseBody public String selectSec(OcDict ocDict, RedirectAttributes redirectAttributes) { System.err.println("ocDict"+JsonMapper.toJsonString(ocDict)); ocDict=ocDictService.get(ocDict); return JsonMapper.toJsonString(ocDict); }
銆€銆€
灏唈son杞崲鎴恖ist
JavaType javaType = JsonMapper.getInstance().createCollectionType(ArrayList.class, DpmProblemReviewInfo.class); List<DpmProblemReviewInfo> objectListData = JsonMapper.getInstance().fromJson(changeData,javaType);
銆€銆€
以上是关于ajax寮傛璇锋眰的主要内容,如果未能解决你的问题,请参考以下文章