首页 > 代码库 > $.ajax等相关用法

$.ajax等相关用法

下面是jquery一些方法的相关用法:

$.ajax:

$.ajax({            type: "GET",            url: "url",            data: {username:$("#username").val(), content:$("#content").val()},
           // data: "username=" + $("#username").val()+ "&content=" + $("#content").val()", contentType:
"application/json; charset=utf-8", dataType: "json", success: function (data) { // Play with returned data in JSON format }, error: function (msg) { alert(msg); } });

 $.getJSON:

$.getJSON(    "url",     { name: "zero", time: "2pm" },     function(json){    alert("JSON Data:");});

$.post:

$.post("url", { "func": "func" },   function(data){     alert(data.name);      console.log(data.time); //  2pm   }, "json");

$.get:

$.get("url", { name: "zero"},  function(data){    alert("Data Loaded: " + data);  });

 

$.ajax等相关用法