標籤:
1.jquery ajax應用
ajax方式
$.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.post( url, [data], [callback], [type] ) :使用POST方式來進行非同步請求
參數:
url (String) : 發送請求的URL地址.
data (Map) : (可選) 要發送給伺服器的資料,以 Key/value 的索引值對形式表示。
callback (Function) : (可選) 載入成功時回呼函數(只有當Response的返回狀態是success才是調用該方法)。
type (String) : (可選)官方的說明是:Type of data to be sent。其實應該為用戶端請求的類型(JSON,XML,等等)
例:
$.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‘);
jquery,javascript常用