日期:2014-05-20  浏览次数:20403 次

Ajax的页面静态化技术。
各位大神。谁做过这样的例子能不能发我一个看看啊 ? 感觉这个搞不清楚。邮箱hzf497852648@qq.com

------解决方案--------------------
其实就是点击的时候回发页面一个值,然后到后台去判断是不是AJAX触发,然后回发一段代码给AJAX,AJAX通过信息的处理重新给控件绑值。。。
前台:
 $(document).ready(function() {
//DOM元素加载之后
//州变动
$("#ctl00_ContentPlaceHolder1_ddl_State").bind("change", function() {
//取州的value
HideStateValue.value = ddl_State.value;
//循环,获取选定项的text值
for (var i = 0; i < ddl_State.length; i++) {
if (ddl_State.options[i].selected == true) {
HideStateText.value = ddl_State.options[i].text;
}
}
//ajax
$.post('region_list_add.aspx', { ajaxtype: '1', key: $(this).children("option:selected").val(), type: '1' },
function(data) {
//分割data
var selectdata = data.split('|');
var code = selectdata[1].split(',');
var Name = selectdata[0].split(',');
//清空
$("#ctl00_ContentPlaceHolder1_ddl_Country").empty();
//循环添加国家信息
for (var i = 0; i < code.length; i++) {
ddl_country[ddl_country.length] = new Option(Name[i], code[i]);
}
if ($("#ctl00_ContentPlaceHolder1_ddl_Country").children("option:selected").val() == "") {
$("#ctl00_ContentPlaceHolder1_ddl_Province").empty();
for (var i = 0; i < code.length; i++) {
ddl_province[ddl_province.length] = new Option(Name[i], code[i]);
}
}
});
});
//国家变动事件
$("#ctl00_ContentPlaceHolder1_ddl_Country").bind("change", function() {
//取选中国家的VALUE
HideCountryValue.value = ddl_country.value;
//循环,获取所选国家的text值
for (var i = 0; i < ddl_country.length; i++) {
if (ddl_country.options[i].selected == true) {
HideCountryText.value = ddl_country.options[i].text;
}
}
//ajax
$.post('region_list_add.aspx', { ajaxtype: '1', key: $(this).children("option:selected").val(), type: '2' }, function(data) {
//处理字符串
var selectdata = data.split('|');
var code = selectdata[1].split(',');
var Name = selectdata[0].split(',');
//清空
$("#ctl00_ContentPlaceHolder1_ddl_Province").empty();
//循环,添加省信息
for (var i = 0; i < code.length; i++) {
ddl_province[ddl_province.length] = new Option(Name[i], code[i]);
}

});
});
//省变动事件
$("#ctl00_ContentPlaceHolder1_ddl_Province").bind("change", function() {
//获取value
HideProvinceValue.value = ddl_province.value;
//循环,获取所选省的text值
for (var i = 0; i < ddl_province.length; i++) {
if (ddl_province.options[i].selected == true) {
HideProvinceText.value = ddl_province.options[i].text;