把ajax改为同步就完了
<script type="text/javascript">
var id= 101;
function add() {
$.ajax({
async: false,
success: function() {
id= 102;
}
})
}
</script>