jQuery GET and POST methods

JQuery

  • What is?

The javascript code skeleton.

  • What is the use?

Simplify coding efficiency.

  • core

write less do more, write less, do more.

load

<a href="" onclick="load()">使用JQuery执行load方法</a>

//有两次刷新,  先走 onClick的方法,取到数据回来之后,赋值显示。 接着 走 href=""的路径,但是这个属性没有给值,所以会把当前的页面重新再刷新一次。所以导致看不见值。

//找到这个元素, 去执行加载的动作, 加载/day16/DemoServlet02 , 得到的数据,赋值显示
$("#aaa").load("/day16/DemoServlet02" , function(responseText , statusTXT  , xhr) {
		//找到id为text01的元素, 设置它的value属性值为 responseText 对应的值
		$("#aaa").val(responseText);
}); 

Get

$.get("/day16/DemoServlet02"  , function(data ,status) {
			$("#div01").text(data);
		});

Assignment display

  • val ( "aa");

load & get

  • load

    $ ( "# Element id") load (url address).;

    $ ( "# Div1") load (serlvet); -.> Use the get request, come back assignment when using text (); to assignment

  • get

    Syntax: $ .get (URL, callback);

Use Cases:

$.get("/day16/DemoServlet02"  , function(data ,status) {
			$("#div01").text(data);
		});
  • post

    . Syntax: $ post (URL, data, callback);

    function post() {
    			$.post("/day16/DemoServlet02", {name:"zhangsan",age:18},function(data,status) {
    				//想要放数据到div里面去。 --- 找到div
    				$("#div01").html(data);
    			});
    		}
    

Is trying to write a blog, the share will give you, if a bad place to write, hope gets advice, thank you!

Original: Big Box  jQuery GET and POST methods


Guess you like

Origin www.cnblogs.com/petewell/p/11421875.html