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

銆€銆€

以上是关于ajax寮傛璇锋眰的主要内容,如果未能解决你的问题,请参考以下文章

鍏充簬HTTP璇锋眰

銆€iOS 缃戠粶璇锋眰缂撳瓨锛歂SURLCache璇﹁В

c#妯℃嫙Http璇锋眰

etrace 璺熻釜 nginx涔婬TTP璇锋眰娴佺▼

灞呬簬HttpWebRequest鐨凥TTP GET/POST璇锋眰

灏忎唬鐮?--http璇锋眰淇℃伅鍐欏叆鏂囦欢