标签:data code 模态框 url 前台 type enc rip led
一、js代码
<script type="text/JavaScript">
$("#save_change_<{$aff.Id}>").click(function(){
//从模态框中取值,并通过ajax传到后台
var account = document.getElementById("change_account_<{$aff.Id}>").value;
var password = document.getElementById("change_password_<{$aff.Id}>").value;
var transactionCrawled = document.getElementById("change_transactionCrawled_<{$aff.Id}>").value;
$.ajax({
type: "POST",
url: "b_aff_aff_change.php",
dataType: "json", //当在前台页面获取后台的msg.account和msg.password是,不标明datatype:"json",是取不到值的!!!
data: "account="+account+"&id=<{$aff.Id}>&password="+password+"&transactionCrawled="+transactionCrawled, //跟url get传参类似,多个值直接加&,变量用+进行连接
success: function(msg){
//通过js改变当前页的td值
document.getElementById("account_<{$aff.Id}>").innerHTML = msg.account;
document.getElementById("password_<{$aff.Id}>").innerHTML = msg.password;
document.getElementById("transactionCrawled_<{$aff.Id}>").innerHTML = msg.transactionCrawled.toUpperCase();
}
});
});
</script>
二、后台页面b_aff_aff_change.PHP
<?php
echo json_encode($_POST); //与ajax中的datatype:"json"相对应,必须先将$_POST数组转换成json格式
?>
标签:data code 模态框 url 前台 type enc rip led
原文地址:http://www.cnblogs.com/Smina/p/7208906.html