通過(guò)Jquery的Ajax方法讀取將table轉(zhuǎn)換為Json
更新時(shí)間:2014年05月31日 16:57:46 作者:
這篇文章主要介紹了通過(guò)Jquery的Ajax方法讀取將table轉(zhuǎn)換為Json,需要的朋友可以參考下
1. 創(chuàng)建Users表
create table Users
(
UserId int identity(1,1) primary key,
UserName varchar(20)
)
insert into Users values('Bradley')
insert into Users values('Dan')
create table Users
(
UserId int identity(1,1) primary key,
UserName varchar(20)
)
insert into Users values('Bradley')
insert into Users values('Dan')
2. 創(chuàng)建JsonHelper類
public class JsonHelper
{
#region 序列化和反序列化
// 序列化
public static string JsonSerializer<T>(T t)
{
// 使用 DataContractJsonSerializer 將 T 對(duì)象序列化為內(nèi)存流。
DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof (T));
MemoryStream ms = new MemoryStream();
// 使用 WriteObject 方法將 JSON 數(shù)據(jù)寫(xiě)入到流中。
jsonSerializer.WriteObject(ms, t);
// 流轉(zhuǎn)字符串
string jsonString = Encoding.UTF8.GetString(ms.ToArray());
ms.Close();
//替換Json的Date字符串
string p = @"\\/Date\((\d+)\+\d+\)\\/";
MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString);
Regex reg = new Regex(p);
jsonString = reg.Replace(jsonString, matchEvaluator);
return jsonString;
}
public static T JsonDeserialize<T>(string jsonString)
{
//將"yyyy-MM-dd HH:mm:ss"格式的字符串轉(zhuǎn)為"\/Date(1294499956278+0800)\/"格式
string p = @"\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}";
MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertDateStringToJsonDate);
Regex reg = new Regex(p);
jsonString = reg.Replace(jsonString, matchEvaluator);
DataContractJsonSerializer jsonSerializer=new DataContractJsonSerializer(typeof(T));
// 字符串轉(zhuǎn)流
MemoryStream ms=new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
// 通過(guò)使用 DataContractJsonSerializer 的 ReadObject 方法,將 JSON 編碼數(shù)據(jù)反序列化為T
T obj = (T) jsonSerializer.ReadObject(ms);
return obj;
}
public static string ConvertJsonDateToDateString(Match match)
{
string result = string.Empty;
DateTime dateTime=new DateTime(1970,1,1);
dateTime = dateTime.AddMilliseconds(long.Parse(match.Groups[1].Value));
dateTime = dateTime.ToLocalTime();
result = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
return result;
}
private static string ConvertDateStringToJsonDate(Match m)
{
string result = string.Empty;
DateTime dt = DateTime.Parse(m.Groups[0].Value);
dt = dt.ToUniversalTime();
TimeSpan ts = dt - DateTime.Parse("1970-01-01");
result = string.Format("\\/Date({0}+0800)\\/",ts.TotalMilliseconds);
return result;
}
#endregion
// 對(duì)象轉(zhuǎn)換為Json
public static string ObjectToJson(object obj)
{
JavaScriptSerializer js=new JavaScriptSerializer();
try
{
return js.Serialize(obj);
}
catch (Exception exception)
{
throw new Exception(exception.Message);
}
}
// 數(shù)據(jù)表轉(zhuǎn)化為集合
public static List<Dictionary<string,object>> DataTableToList(DataTable dt)
{
List<Dictionary<string ,object>> list=new List<Dictionary<string, object>>();
foreach (DataRow dataRow in dt.Rows)
{
Dictionary<string,object> dic=new Dictionary<string, object>();
foreach (DataColumn dc in dt.Columns)
{
dic.Add(dc.ColumnName,dataRow[dc.ColumnName]);
}
list.Add(dic);
}
return list;
}
// 表轉(zhuǎn)換為Json
public static string DataTableToJson(DataTable dt)
{
return ObjectToJson(DataTableToList(dt));
}
}
public class JsonHelper
{
#region 序列化和反序列化
// 序列化
public static string JsonSerializer<T>(T t)
{
// 使用 DataContractJsonSerializer 將 T 對(duì)象序列化為內(nèi)存流。
DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof (T));
MemoryStream ms = new MemoryStream();
// 使用 WriteObject 方法將 JSON 數(shù)據(jù)寫(xiě)入到流中。
jsonSerializer.WriteObject(ms, t);
// 流轉(zhuǎn)字符串
string jsonString = Encoding.UTF8.GetString(ms.ToArray());
ms.Close();
//替換Json的Date字符串
string p = @"\\/Date\((\d+)\+\d+\)\\/";
MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString);
Regex reg = new Regex(p);
jsonString = reg.Replace(jsonString, matchEvaluator);
return jsonString;
}
public static T JsonDeserialize<T>(string jsonString)
{
//將"yyyy-MM-dd HH:mm:ss"格式的字符串轉(zhuǎn)為"\/Date(1294499956278+0800)\/"格式
string p = @"\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}";
MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertDateStringToJsonDate);
Regex reg = new Regex(p);
jsonString = reg.Replace(jsonString, matchEvaluator);
DataContractJsonSerializer jsonSerializer=new DataContractJsonSerializer(typeof(T));
// 字符串轉(zhuǎn)流
MemoryStream ms=new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
// 通過(guò)使用 DataContractJsonSerializer 的 ReadObject 方法,將 JSON 編碼數(shù)據(jù)反序列化為T
T obj = (T) jsonSerializer.ReadObject(ms);
return obj;
}
public static string ConvertJsonDateToDateString(Match match)
{
string result = string.Empty;
DateTime dateTime=new DateTime(1970,1,1);
dateTime = dateTime.AddMilliseconds(long.Parse(match.Groups[1].Value));
dateTime = dateTime.ToLocalTime();
result = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
return result;
}
private static string ConvertDateStringToJsonDate(Match m)
{
string result = string.Empty;
DateTime dt = DateTime.Parse(m.Groups[0].Value);
dt = dt.ToUniversalTime();
TimeSpan ts = dt - DateTime.Parse("1970-01-01");
result = string.Format("\\/Date({0}+0800)\\/",ts.TotalMilliseconds);
return result;
}
#endregion
// 對(duì)象轉(zhuǎn)換為Json
public static string ObjectToJson(object obj)
{
JavaScriptSerializer js=new JavaScriptSerializer();
try
{
return js.Serialize(obj);
}
catch (Exception exception)
{
throw new Exception(exception.Message);
}
}
// 數(shù)據(jù)表轉(zhuǎn)化為集合
public static List<Dictionary<string,object>> DataTableToList(DataTable dt)
{
List<Dictionary<string ,object>> list=new List<Dictionary<string, object>>();
foreach (DataRow dataRow in dt.Rows)
{
Dictionary<string,object> dic=new Dictionary<string, object>();
foreach (DataColumn dc in dt.Columns)
{
dic.Add(dc.ColumnName,dataRow[dc.ColumnName]);
}
list.Add(dic);
}
return list;
}
// 表轉(zhuǎn)換為Json
public static string DataTableToJson(DataTable dt)
{
return ObjectToJson(DataTableToList(dt));
}
}
3. 添加ashx代碼文件
public class GetData : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
if (context.Request["action"]=="display")
{
context.Response.Write(JsonHelper.DataTableToJson(GetAllUsers()));
}
}
static SqlConnection conn = new SqlConnection("server=.;database=Test;uid=sa;pwd=123456");
public static DataTable GetAllUsers()
{
string sql = "select * from users";
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
DataTable dt = new DataTable();
adapter.Fill(dt);
return dt;
}
public bool IsReusable
{
get
{
return false;
}
}
}
public class GetData : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
if (context.Request["action"]=="display")
{
context.Response.Write(JsonHelper.DataTableToJson(GetAllUsers()));
}
}
static SqlConnection conn = new SqlConnection("server=.;database=Test;uid=sa;pwd=123456");
public static DataTable GetAllUsers()
{
string sql = "select * from users";
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
DataTable dt = new DataTable();
adapter.Fill(dt);
return dt;
}
public bool IsReusable
{
get
{
return false;
}
}
}
4. 前端調(diào)用
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script src="js/jquery-1.6.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
var options = {
type: 'post',
url: "/GetData.ashx",
dataType: "json",
data: { action: "display" },
success: function(data) {
var html = "<table border='2px' style='text-align:center;border-style:solid;border-width:2px;border-color:#00ff00;'><tr><td>UserId</td><td>UserName</td></tr>";
$.each(data, function(i, result) {
html += "<tr><td>" + result["UserId"] + "</td><td>" + result["UserName"] + "</td></tr>";
})
html += "</table>";
$("#divData").html(html);
}
};
$.ajax(options);
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="divData">
</div>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script src="js/jquery-1.6.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
var options = {
type: 'post',
url: "/GetData.ashx",
dataType: "json",
data: { action: "display" },
success: function(data) {
var html = "<table border='2px' style='text-align:center;border-style:solid;border-width:2px;border-color:#00ff00;'><tr><td>UserId</td><td>UserName</td></tr>";
$.each(data, function(i, result) {
html += "<tr><td>" + result["UserId"] + "</td><td>" + result["UserName"] + "</td></tr>";
})
html += "</table>";
$("#divData").html(html);
}
};
$.ajax(options);
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="divData">
</div>
</form>
</body>
</html>
5. 效果圖
6. 同樣可以通過(guò)getJSON方法讀取數(shù)據(jù)
$.getJSON("/GetData.ashx",{ action: "display" },function(data) {
var html = "<table border='2px' style='text-align:center;border-style:solid;border-width:2px;border-color:#00ff00;'><tr><td>UserId</td><td>UserName</td></tr>";
$.each(data, function(i, result) {
html += "<tr><td>" + result["UserId"] + "</td><td>" + result["UserName"] + "</td></tr>";
})
html += "</table>";
$("#divData").html(html);
})
$.getJSON("/GetData.ashx",{ action: "display" },function(data) {
var html = "<table border='2px' style='text-align:center;border-style:solid;border-width:2px;border-color:#00ff00;'><tr><td>UserId</td><td>UserName</td></tr>";
$.each(data, function(i, result) {
html += "<tr><td>" + result["UserId"] + "</td><td>" + result["UserName"] + "</td></tr>";
})
html += "</table>";
$("#divData").html(html);
})
復(fù)制代碼 代碼如下:
create table Users
(
UserId int identity(1,1) primary key,
UserName varchar(20)
)
insert into Users values('Bradley')
insert into Users values('Dan')
復(fù)制代碼 代碼如下:
create table Users
(
UserId int identity(1,1) primary key,
UserName varchar(20)
)
insert into Users values('Bradley')
insert into Users values('Dan')
2. 創(chuàng)建JsonHelper類
復(fù)制代碼 代碼如下:
public class JsonHelper
{
#region 序列化和反序列化
// 序列化
public static string JsonSerializer<T>(T t)
{
// 使用 DataContractJsonSerializer 將 T 對(duì)象序列化為內(nèi)存流。
DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof (T));
MemoryStream ms = new MemoryStream();
// 使用 WriteObject 方法將 JSON 數(shù)據(jù)寫(xiě)入到流中。
jsonSerializer.WriteObject(ms, t);
// 流轉(zhuǎn)字符串
string jsonString = Encoding.UTF8.GetString(ms.ToArray());
ms.Close();
//替換Json的Date字符串
string p = @"\\/Date\((\d+)\+\d+\)\\/";
MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString);
Regex reg = new Regex(p);
jsonString = reg.Replace(jsonString, matchEvaluator);
return jsonString;
}
public static T JsonDeserialize<T>(string jsonString)
{
//將"yyyy-MM-dd HH:mm:ss"格式的字符串轉(zhuǎn)為"\/Date(1294499956278+0800)\/"格式
string p = @"\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}";
MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertDateStringToJsonDate);
Regex reg = new Regex(p);
jsonString = reg.Replace(jsonString, matchEvaluator);
DataContractJsonSerializer jsonSerializer=new DataContractJsonSerializer(typeof(T));
// 字符串轉(zhuǎn)流
MemoryStream ms=new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
// 通過(guò)使用 DataContractJsonSerializer 的 ReadObject 方法,將 JSON 編碼數(shù)據(jù)反序列化為T
T obj = (T) jsonSerializer.ReadObject(ms);
return obj;
}
public static string ConvertJsonDateToDateString(Match match)
{
string result = string.Empty;
DateTime dateTime=new DateTime(1970,1,1);
dateTime = dateTime.AddMilliseconds(long.Parse(match.Groups[1].Value));
dateTime = dateTime.ToLocalTime();
result = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
return result;
}
private static string ConvertDateStringToJsonDate(Match m)
{
string result = string.Empty;
DateTime dt = DateTime.Parse(m.Groups[0].Value);
dt = dt.ToUniversalTime();
TimeSpan ts = dt - DateTime.Parse("1970-01-01");
result = string.Format("\\/Date({0}+0800)\\/",ts.TotalMilliseconds);
return result;
}
#endregion
// 對(duì)象轉(zhuǎn)換為Json
public static string ObjectToJson(object obj)
{
JavaScriptSerializer js=new JavaScriptSerializer();
try
{
return js.Serialize(obj);
}
catch (Exception exception)
{
throw new Exception(exception.Message);
}
}
// 數(shù)據(jù)表轉(zhuǎn)化為集合
public static List<Dictionary<string,object>> DataTableToList(DataTable dt)
{
List<Dictionary<string ,object>> list=new List<Dictionary<string, object>>();
foreach (DataRow dataRow in dt.Rows)
{
Dictionary<string,object> dic=new Dictionary<string, object>();
foreach (DataColumn dc in dt.Columns)
{
dic.Add(dc.ColumnName,dataRow[dc.ColumnName]);
}
list.Add(dic);
}
return list;
}
// 表轉(zhuǎn)換為Json
public static string DataTableToJson(DataTable dt)
{
return ObjectToJson(DataTableToList(dt));
}
}
復(fù)制代碼 代碼如下:
public class JsonHelper
{
#region 序列化和反序列化
// 序列化
public static string JsonSerializer<T>(T t)
{
// 使用 DataContractJsonSerializer 將 T 對(duì)象序列化為內(nèi)存流。
DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof (T));
MemoryStream ms = new MemoryStream();
// 使用 WriteObject 方法將 JSON 數(shù)據(jù)寫(xiě)入到流中。
jsonSerializer.WriteObject(ms, t);
// 流轉(zhuǎn)字符串
string jsonString = Encoding.UTF8.GetString(ms.ToArray());
ms.Close();
//替換Json的Date字符串
string p = @"\\/Date\((\d+)\+\d+\)\\/";
MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertJsonDateToDateString);
Regex reg = new Regex(p);
jsonString = reg.Replace(jsonString, matchEvaluator);
return jsonString;
}
public static T JsonDeserialize<T>(string jsonString)
{
//將"yyyy-MM-dd HH:mm:ss"格式的字符串轉(zhuǎn)為"\/Date(1294499956278+0800)\/"格式
string p = @"\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}";
MatchEvaluator matchEvaluator = new MatchEvaluator(ConvertDateStringToJsonDate);
Regex reg = new Regex(p);
jsonString = reg.Replace(jsonString, matchEvaluator);
DataContractJsonSerializer jsonSerializer=new DataContractJsonSerializer(typeof(T));
// 字符串轉(zhuǎn)流
MemoryStream ms=new MemoryStream(Encoding.UTF8.GetBytes(jsonString));
// 通過(guò)使用 DataContractJsonSerializer 的 ReadObject 方法,將 JSON 編碼數(shù)據(jù)反序列化為T
T obj = (T) jsonSerializer.ReadObject(ms);
return obj;
}
public static string ConvertJsonDateToDateString(Match match)
{
string result = string.Empty;
DateTime dateTime=new DateTime(1970,1,1);
dateTime = dateTime.AddMilliseconds(long.Parse(match.Groups[1].Value));
dateTime = dateTime.ToLocalTime();
result = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
return result;
}
private static string ConvertDateStringToJsonDate(Match m)
{
string result = string.Empty;
DateTime dt = DateTime.Parse(m.Groups[0].Value);
dt = dt.ToUniversalTime();
TimeSpan ts = dt - DateTime.Parse("1970-01-01");
result = string.Format("\\/Date({0}+0800)\\/",ts.TotalMilliseconds);
return result;
}
#endregion
// 對(duì)象轉(zhuǎn)換為Json
public static string ObjectToJson(object obj)
{
JavaScriptSerializer js=new JavaScriptSerializer();
try
{
return js.Serialize(obj);
}
catch (Exception exception)
{
throw new Exception(exception.Message);
}
}
// 數(shù)據(jù)表轉(zhuǎn)化為集合
public static List<Dictionary<string,object>> DataTableToList(DataTable dt)
{
List<Dictionary<string ,object>> list=new List<Dictionary<string, object>>();
foreach (DataRow dataRow in dt.Rows)
{
Dictionary<string,object> dic=new Dictionary<string, object>();
foreach (DataColumn dc in dt.Columns)
{
dic.Add(dc.ColumnName,dataRow[dc.ColumnName]);
}
list.Add(dic);
}
return list;
}
// 表轉(zhuǎn)換為Json
public static string DataTableToJson(DataTable dt)
{
return ObjectToJson(DataTableToList(dt));
}
}
3. 添加ashx代碼文件
復(fù)制代碼 代碼如下:
public class GetData : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
if (context.Request["action"]=="display")
{
context.Response.Write(JsonHelper.DataTableToJson(GetAllUsers()));
}
}
static SqlConnection conn = new SqlConnection("server=.;database=Test;uid=sa;pwd=123456");
public static DataTable GetAllUsers()
{
string sql = "select * from users";
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
DataTable dt = new DataTable();
adapter.Fill(dt);
return dt;
}
public bool IsReusable
{
get
{
return false;
}
}
}
復(fù)制代碼 代碼如下:
public class GetData : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
if (context.Request["action"]=="display")
{
context.Response.Write(JsonHelper.DataTableToJson(GetAllUsers()));
}
}
static SqlConnection conn = new SqlConnection("server=.;database=Test;uid=sa;pwd=123456");
public static DataTable GetAllUsers()
{
string sql = "select * from users";
SqlDataAdapter adapter = new SqlDataAdapter(sql, conn);
DataTable dt = new DataTable();
adapter.Fill(dt);
return dt;
}
public bool IsReusable
{
get
{
return false;
}
}
}
4. 前端調(diào)用
復(fù)制代碼 代碼如下:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script src="js/jquery-1.6.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
var options = {
type: 'post',
url: "/GetData.ashx",
dataType: "json",
data: { action: "display" },
success: function(data) {
var html = "<table border='2px' style='text-align:center;border-style:solid;border-width:2px;border-color:#00ff00;'><tr><td>UserId</td><td>UserName</td></tr>";
$.each(data, function(i, result) {
html += "<tr><td>" + result["UserId"] + "</td><td>" + result["UserName"] + "</td></tr>";
})
html += "</table>";
$("#divData").html(html);
}
};
$.ajax(options);
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="divData">
</div>
</form>
</body>
</html>
復(fù)制代碼 代碼如下:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script src="js/jquery-1.6.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
var options = {
type: 'post',
url: "/GetData.ashx",
dataType: "json",
data: { action: "display" },
success: function(data) {
var html = "<table border='2px' style='text-align:center;border-style:solid;border-width:2px;border-color:#00ff00;'><tr><td>UserId</td><td>UserName</td></tr>";
$.each(data, function(i, result) {
html += "<tr><td>" + result["UserId"] + "</td><td>" + result["UserName"] + "</td></tr>";
})
html += "</table>";
$("#divData").html(html);
}
};
$.ajax(options);
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="divData">
</div>
</form>
</body>
</html>
5. 效果圖

6. 同樣可以通過(guò)getJSON方法讀取數(shù)據(jù)
復(fù)制代碼 代碼如下:
$.getJSON("/GetData.ashx",{ action: "display" },function(data) {
var html = "<table border='2px' style='text-align:center;border-style:solid;border-width:2px;border-color:#00ff00;'><tr><td>UserId</td><td>UserName</td></tr>";
$.each(data, function(i, result) {
html += "<tr><td>" + result["UserId"] + "</td><td>" + result["UserName"] + "</td></tr>";
})
html += "</table>";
$("#divData").html(html);
})
復(fù)制代碼 代碼如下:
$.getJSON("/GetData.ashx",{ action: "display" },function(data) {
var html = "<table border='2px' style='text-align:center;border-style:solid;border-width:2px;border-color:#00ff00;'><tr><td>UserId</td><td>UserName</td></tr>";
$.each(data, function(i, result) {
html += "<tr><td>" + result["UserId"] + "</td><td>" + result["UserName"] + "</td></tr>";
})
html += "</table>";
$("#divData").html(html);
})
您可能感興趣的文章:
- jQuery+json實(shí)現(xiàn)動(dòng)態(tài)創(chuàng)建復(fù)雜表格table的方法
- JQuery實(shí)現(xiàn)table行折疊效果以JSON做數(shù)據(jù)源
- jQuery通過(guò)ajax請(qǐng)求php遍歷json數(shù)組到table中的代碼(推薦)
- js實(shí)現(xiàn)將json數(shù)組顯示前臺(tái)table中
- js中將字符串轉(zhuǎn)換成json的三種方式
- 解析JSON對(duì)象與字符串之間的相互轉(zhuǎn)換
- JS對(duì)象與JSON格式數(shù)據(jù)相互轉(zhuǎn)換
- JQuery遍歷json數(shù)組的3種方法
- 使用jsonp完美解決跨域問(wèn)題
- jQuery中讀取json文件示例代碼
- js與jQuery實(shí)現(xiàn)獲取table中的數(shù)據(jù)并拼成json字符串操作示例
相關(guān)文章
jquery清空input標(biāo)簽的值及清除標(biāo)簽里面的內(nèi)容
這篇文章主要介紹了jquery清空input標(biāo)簽的值,清除標(biāo)簽里面的內(nèi)容,清除input標(biāo)簽的值,可以通過(guò)直接將input標(biāo)簽的值設(shè)置為空來(lái)實(shí)現(xiàn),本文通過(guò)示例代碼給大家介紹的非常詳細(xì),需要的朋友參考下吧2023-10-10將鼠標(biāo)焦點(diǎn)定位到文本框最后(代碼分享)
本文主要分享了將鼠標(biāo)焦點(diǎn)定位到文本框最后的實(shí)例代碼。具有很好的參考價(jià)值,下面跟著小編一起來(lái)看下吧2017-01-01jquery form表單提交插件asp.net后臺(tái)中文解碼
對(duì)于jquery form表單提交插件jquery.form.js,在提交表單數(shù)據(jù)時(shí),如果表單數(shù)據(jù)有中文,則被提交的數(shù)據(jù)是要經(jīng)過(guò)編碼的。2010-06-06淺析ajax請(qǐng)求json數(shù)據(jù)并用js解析(示例分析)
這應(yīng)該是每個(gè)web開(kāi)發(fā)的人員都應(yīng)該掌握的基礎(chǔ)技術(shù),需要的朋友可以參考下2013-07-07