前端之家收集整理的这篇文章主要介绍了
Ajax($.getJSON使用实例),
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<script type="text/javascript">
function pageIndexChanged() {
var url = "/OrderList/Lists";
var where = "";
@*location.href = "@this.Url.Action("List")?pageindex=" + $("#pager").pager("pageindex") + "&pagesize=" + $("#pager").pager("pagesize") + "&where=" + escape(where);*@
var pageindex = $("#pager").pager("pageindex");
var pagesize = $("#pager").pager("pagesize");
where = escape(where);
$.getJSON(url,{ where: where,pageindex: pageindex,pagesize: pagesize },function (data) {
alert(data.total);
alert(data.rows[0].Order.OrderID);
alert(data.PageIndex);
alert(data.PageSize);
});
}
$(function () {
$("#order-details-search").click(function () {
$(".detail-search").show(100);
});
$("#detail_search_cancle").click(function () {
$(".detail-search").hide(100);
})
});
</script>
var cache = {};
var data;
$("#seachers").autocomplete(
{
source: function (request,response) {
var term = request.term;
if (term in cache) {
data = cache[term];
response($.map(data.NameList,function (item) {
return { label: item.ProjectName };
}));
} else {
$.ajax({
url: "@this.Url.Action("AutoGet","Project")",dateType: "jsonp",data: {
top: 10,key: request.term
},success: function (data) {
if (data.NameList.length) {
cache[term] = data;
response($.map(data.NameList,function (item) {
return { label: item.ProjectName };
}));
}
}
});
}
},minLength: 1,autoFocus: false,delay: 500
});
原文链接:https://www.f2er.com/ajax/166704.html