MVC Json Ajax 二级 级连
<script type="text/javascript">
$(document).ready(function() {
$("#teamName").change(function() {
$.getJSON('/team/SelectProduct', { teamName: $("#teamName").val() }, function(data) {
$("#productID").empty();
$.each(data, function(i, item) {
$("<option></option>")
.val(item)
.text(item)
.appendTo($("#productID"))
});
});
})
});
controller:
public ActionResult SelectProduct()
{
string teamName = Request.Params["teamName"];
int teamID = dc.TestTeams.Where(x => x.Name == teamName).SingleOrDefault().Id;
var productCollection = dc.Products.Where(x => x.TestTeamId == teamID).Select(x=> x.ShortName);
return Json(productCollection);
}
相关文档:
1. http://hi.baidu.com/lshun/blog/item/2378b4c36fdef455b219a85b.html
CODE:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<pets>
<猫 />
<狗 />
< ......
从数据库my中的username用户表里验证:
checkusername.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" conte ......
利用AJAX动态获取当前时间,客户端time.php,服务器端time_check.php
客户端代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv=" ......