AJAx 具體案例。

2021-06-03 13:25:01 字數 1354 閱讀 9564

1.在專案中新增此dll的應用,同時需要在 webconfig的 裡面 加上

2.在應用頁面的page_load中新增

ajax.utility.registertypeforajax(typeof(頁面名));

3.在要呼叫的後台方法前加ajax的宣告

①操作session時

②其他操作的時候

[ajax.ajaxmethod()]

public datatable dependlinegetbranch(string strlinecd)

4.在前台的js中寫function中呼叫此方法

var abc=頁面名.方法名(引數).value;//有返回值

頁面名.方法名(引數);//沒有返回值

③注意點

(1).不可以讀取 cookie的值,但是可讀session的值 不能使用request去引數值,不能使用控制項名字

(2)方法中不能出現後台的控制項,比如 this.***x 會提示[未定義]

(3)不能呼叫過載方法,如果過載方法將呼叫失敗。

案例**如下

前台**:

<%@ page language="c#" autoeventwireup="true" codefile="ajaxexample.aspx.cs" inherits="ajaxexample" %>

後台**:

using system;

using system.data;

using system.configuration;

using system.collections;

using system.web;

using system.web.security;

using system.web.ui;

using system.web.ui.webcontrols;

using system.web.ui.webcontrols.webparts;

using system.web.ui.htmlcontrols;

public partial class ajaxexample : system.web.ui.page

[ajax.ajaxmethod()]

public string writetext()

public void changelabel()

}

ajax簡單案例

jquery 自帶的 ajax 函式簡單案例 自定義構造乙個特定的函式用來通用請求 的形式 success success,error fail 呼叫http函式來請求介面並獲取資料 1.資料格式 2.js jquery function function get url 這行不能省略,如果沒有資料...

游標使用具體案例

drop procedure if exists workingday insert 建立儲存過程 create procedure workingday insert begin declare num int default 0 declare centguid sp varchar 100 申...

ajax請求(模板 案例)

ajax 請求的資料,規定連同請求傳送到伺服器的資料 data1 async false 是否非同步 預設為true success function data error function data 注 以上兩個data data1,data2 意義不同 乙個是傳出的資料 乙個是傳回的資料。aja...