jquery,javascript經常使用

1.jquery ajax應用php

ajax方式 html

$.ajax({ url: 'stat.php',

type: 'POST',

data:{Name:"keyun"},

dataType: 'html',

timeout: 1000,

error: function(){alert('Error loading PHP document');},

success: function(result){alert(result);}

});

 

post 方式 jquery

jQuery.post( url, [data], [callback], [type] ) :使用POST方式來進行異步請求ajax

參數:json

url (String) : 發送請求的URL地址.服務器

data (Map) : (可選) 要發送給服務器的數據,以 Key/value 的鍵值對形式表示。異步

callback (Function) : (可選) 載入成功時回調函數(只有當Response的返回狀態是success纔是調用該方法)。函數

type (String) : (可選)官方的說明是:Type of data to be sent。其實應該爲客戶端請求的類型(JSON,XML,等等)post

例:this

 

$.post("Ajax.aspx", { Action: "post", Name: "lulu" },     
   function (data, textStatus){        
    // data 能夠是 xmlDoc, jsonObj, html, text, 等等.  
    //this;
    // 這個Ajax請求的選項配置信息,請參考jQuery.get()說到的this  
   alert(data.result);        }, "json");

 

2.jquery 經常使用標籤

 

//attr輸出屬性的值,屬性名還能夠自定義
//att 參數若是是class, 輸出就是class的值RemoveLink    $(".RemoveLink").attr("class");
var recordid = $(".RemoveLink").attr("data-id");
 <a href="#" class="RemoveLink" data-id="@item.RecordId">Remove</a>


// 訪問table中td的值
$('#item').text()


3.jquery 特效

 //$(selector).fadeOut(speed,callback) 淡出效果 speed:•毫秒 (好比 1500)•"slow"•"normal"•"fast"; 默認normal
                    $('#row' ).fadeOut('slow');
相關文章
相關標籤/搜索