代码一:
$.ajax({ url: "AjaxPassenger.aspx", cache: false, data: "Date=" new Date() "&cPassengerName=" encodeURI(ctxtName) "&CerType=" cddlCerType "&CerNo=" ctxtCerNo "&Phone=" ctxtPhone "&validateKey=validateKey&Num=1", async: false, success: function(count) { $("#cspanPageTotalCount").text(count); } });
代码二: $.getJSON("AjaxPassenger.aspx", { Date: new Date(), cPassengerName: ctxtName, CerType: cddlCerType, CerNo: ctxtCerNo, Phone: ctxtPhone, PageIndex: PageIndex, validateKey: "validateKey" }, function(json) { var html = "<tr><th>中文名称</th><th>证件类型</th><th>证件号</th><th>电话</th> <th>操作</th></tr>"; if (json.length > 0) { for (var i = 0; i < json.length; i ) { html = "<tr align=\"center\"><td>" json[i].ChineseName "</td><td>" CertypeList(json[i].CerType) "</td><td>" json[i].CertificateNo "</td><td>" json[i].Phone "</td><td><span onclick=\"btnxianzhe(this)\">选择</span></tr></td>"; } } else { html = "<tr><td colspan=\"5\">您当前还没有常旅客</td></tr>"; } $("#tabPassenger").html(html); });
请问这两段代码有啥区别?给我感觉都是异步调用得到返回值,为什么一个用 $.ajax一个用$.getJSON,难道是一个是接收集合,一个是单个对象么?
- 2 回答
- 0 关注
- 285 浏览
添加回答
举报
0/150
提交
取消