Callback的範列
by thomascsd
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div id="msg">
</div>
<div id="msg2">
</div>
JavaScript
var json = {
msg: 'hello ng'
};
var json2 = {
msg: 'hello ng2'
};
var data = {
json: JSON.stringify(json)
};
var data2 = {
json: JSON.stringify(json2)
}
$.post('/echo/json/', data, (ret) => {
$('#msg').html(ret.msg);
$.post('/echo/json/', data2, (ret2) => {
$('#msg2').html(ret2.msg);
});
});