码迷,mamicode.com
首页 > Web开发 > 详细

$.ajax等相关用法

时间:2014-12-01 12:48:17      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   ar   color   os   sp   for   on   

下面是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等相关用法

标签:style   blog   io   ar   color   os   sp   for   on   

原文地址:http://www.cnblogs.com/zxiong/p/4134664.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!