JQuery简介
JQuery简介
Demo:
1..ajax请求-->Get
<html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#b01").click(function(){ htmlobj=$.ajax({url:"/jquery/test1.txt",async:false}); $("#myDiv").html(htmlobj.responseText); }); }); </script> </head> <body> <div id="myDiv"><h2>通过 AJAX 改变文本</h2></div> <button id="b01" type="button">改变内容</button> </body> </html>
2.Get请求:
<!DOCTYPE html> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $.get("/example/jquery/demo_test.asp",function(data,status){ alert("数据:" + data + "\n状态:" + status); }); }); }); </script> </head> <body> <button>向页面发送 HTTP GET 请求,然后获得返回的结果</button> </body> </html>
3.Post请求:
<!DOCTYPE html> <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $.post("/example/jquery/demo_test_post.asp", { name:"Donald Duck", city:"Duckburg" }, function(data,status){ alert("数据:" + data + "\n状态:" + status); }); }); }); </script> </head> <body> <button>向页面发送 HTTP POST 请求,并获得返回的结果</button> </body> </html>
<% dim fname,city fname=Request.Form("name") city=Request.Form("city") Response.Write("Dear " & fname & ". ") Response.Write("Hope you live well in " & city & ".") %>
4..ajax-->Get请求:
function Play(videoId){ var videoName= $("#videoName").val();//将页面上id="videoName"的值拿过来 $.ajax({ type : "GET", url : "/video/getVideoPlayURL?videoId="+videoId+"&videoName="+videoName, dataType : "text", //json success : function(data) { var ret = eval(data);//data为controller返回的数据,将它转成ret对象 $("#jishu").val(ret.jishu);//将ret对象中jishu值赋到id="jishu"中 }}); } <a href="javascript:void(0)" onclick="Play(${video.id})">Ajax请求</a> a.dataType:"text" String videoURL = "ajax返回的字符串"; return "@" + videoURL; b.dataType:"json" Map<String,Object> urlMap = new HashMap<String,Object>(); urlMap.put("jishu", newjishu); urlMap.put("url", videoURL); String result = JSONObject.fromObject(urlMap).toString(); return "@" + result;
http://www.w3school.com.cn/jquery/
相关推荐
TONIYH 2020-07-22
83510998 2020-07-18
wcqwcq 2020-06-26
delmarks 2020-06-14
ppsurcao 2020-06-14
tthappyer 2020-06-07
EdwardSiCong 2020-11-23
85477104 2020-11-17
hhanbj 2020-11-17
81427005 2020-11-11
seoppt 2020-09-13
honeyth 2020-09-13
WRITEFORSHARE 2020-09-13
84483065 2020-09-11
momode 2020-09-11
85477104 2020-08-15
83510998 2020-08-08